Delete an ODBC entry: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.)
m (Updated author links.)
Line 1: Line 1:
{|align=right
|<small>Author: [[{{ns:2}}:preisl|preisl]] ([[{{ns:3}}:preisl|talk]], [[{{ns:-1}}:Contributions/preisl|contrib]])</small>
|}
<br style="clear:both;">
== The Function ==
== The Function ==
<highlight-nsis>
<highlight-nsis>
Line 65: Line 69:
FunctionEnd
FunctionEnd
</highlight-nsis>
</highlight-nsis>
Page author: [[User:preisl|preisl]]

Revision as of 23:28, 29 April 2005

Author: preisl (talk, contrib)


The Function

;
; Delete an existing ODBC Entry
;
; Requires: ODBCEntryExists
;    Input: Name of the ODBC entry
;   Output: None
;
; Usage:
;
;    Push "ODBCTEST"
;    Call DeleteODBCEntry
;    MessageBox MB_OK|MB_ICONINFORMATION "ODBC entry 'ODBCTEST' deleted"
;
 
!macro DeleteODBCEntryMacro PREFIX
 
  ; Clear all errors first
  ClearErrors
  ; Pop the name of the ODBC entry from the stack
  Exch $R0
  Push $R1
 
  IfErrors InvalidParameter DeleteEntry
  InvalidParameter:
    MessageBox MB_OK|MB_ICONEXCLAMATION "DeleteODBCEntry: Please push the name of the ODBC entry first."
    Goto Done
 
  DeleteEntry:
 
    ; Check whether the ODBC entry already exists
    Push $R0
    Call ${PREFIX}ODBCEntryExists
    Pop $R1
    StrCmp $R1 "FALSE" Done
 
    ; Delete the registry keys
    ClearErrors
    DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\ODBC\ODBC.INI\$R0"
    IfErrors ErrorKey DeleteValue
    ErrorKey:
      MessageBox MB_OK|MB_ICONEXCLAMATION "Could not delete the registry key:$\r$\rHKLM - SOFTWARE\ODBC\ODBC.INI\$R0$\r$\rPlease delete this registry key manually !"
    DeleteValue:
    ClearErrors
    DeleteRegValue HKEY_LOCAL_MACHINE "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources" "$R0"
    IfErrors ErrorValue Done
    ErrorValue:
      MessageBox MB_OK|MB_ICONEXCLAMATION "Could not delete the registry value:$\r$\rHKLM - SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\$R0$\r$\rPlease delete this registry value manually !"
 
  Done:
 
  ; Restore R0-R1
  Pop $R1
  Pop $R0
 
!macroend
 
Function DeleteODBCEntry
  !insertmacro DeleteODBCEntryMacro ""
FunctionEnd
 
Function un.DeleteODBCEntry
  !insertmacro DeleteODBCEntryMacro "un."
FunctionEnd