25. februar 2003 - 10:52Der er
8 kommentarer og 1 løsning
igen igen unreg activex komponent
jeg skal unregge en activex komponent
har prøvet at bruge det her eksempel jeg har lavet ud fra et post fra shj koden kommer her:
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Any, ByVal wParam As Any, ByVal lParam As Any) As Long Private Const ERROR_SUCCESS = &H0
Private Sub cmdUnpoint_Click()
If optExcel.Value = True Then txtName.Caption = "xpoint30_excel.ocx" End If Call RegisterServer(Me.hWnd, txtName.Caption, False) End Sub
Public Function RegisterServer(hWnd As Long, DllServerPath As String, bRegister As Boolean) On Error Resume Next Dim lb As Long, pa As Long lb = LoadLibrary(DllServerPath) If bRegister Then pa = GetProcAddress(lb, "DllRegisterServer") Else pa = GetProcAddress(lb, "DllUnregisterServer") End If
If CallWindowProc(pa, hWnd, ByVal 0&, ByVal 0&, ByVal 0&) = ERROR_SUCCESS Then MsgBox IIf(bRegister = True, "Registration", "Unregistration") + " Successful" Else MsgBox IIf(bRegister = True, "Registration", "Unregistration") + " Unsuccessful" End If FreeLibrary lb End Function
Private Sub cmdExit_Click() End End Sub
og jeg har prøvet at bruge shell kommandoen til at køre regsvr32 men med begge dele er komponenten stadig regget bagefter og virker fuldt ud og det er jo ikek så fedt hehe koden til shell forsøget kommer her:
Public Sub Unreg() txtStatus.Caption = "Unregistering..." Shell ("regsvr32.exe /u /s " & txtName.Caption) txtStatus.Caption = "Done." End Sub
Private Sub cmdUnpoint_Click()
If optExcel.Value = True Then txtName.Caption = "xpoint30_excel.ocx"
End If
If optDeveloper.Value = True Then txtName.Caption = "xpoint30_excel.ocx" End If
If optRuntime.Value = True Then txtName.Caption = "xpoint30_excel.ocx" End If Call Unreg End Sub
Private Sub cmdExit_Click() End End Sub
Private Sub optDeveloper_Click() txtStatus.Caption = "X@Point Developer 3.0" End Sub
Private Sub optExcel_Click() txtStatus.Caption = "X@Point Excel 3.0" End Sub
Private Sub optRuntime_Click() txtStatus.Caption = "X@Point Viewer 3.0" End Sub
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _ (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" _ (ByVal hLibModule As Long) As Long
Private Declare Function GetProcAddress Lib "kernel32" _ (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function CreateThread Lib "kernel32" _ (lpThreadAttributes As Any, ByVal dwStackSize As Long, _ lpStartAddress As Long, lpParameter As Any, _ ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" _ (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _ (ByVal hObject As Long) As Long
Private Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)
Private Declare Function ResumeThread Lib "kernel32" _ (ByVal hThread As Long) As Long
Private Declare Function GetExitCodeThread Lib "kernel32" _ (ByVal hThread As Long, lpExitCode As Long) As Long
Public Function fVBRegServer(ByVal strFilePath As String, _ Optional ByVal blnRegister = True) As Boolean
Dim lngModuleHandle As Long ' module handle Dim lngFunctionAdr As Long ' reg/unreg function address Dim lngThreadID As Long ' dummy var that get's filled Dim lngThreadHandle As Long ' thread handle Dim lngExitCode As Long ' thread's exit code if it doesn't finish Dim blnSuccess As Boolean ' if things worked
' ' Load the file into memory. ' lngModuleHandle = LoadLibrary(strFilePath)
' ' Get the registration function's address. ' If blnRegister Then lngFunctionAdr = GetProcAddress(lngModuleHandle, "DllRegisterServer") Else lngFunctionAdr = GetProcAddress(lngModuleHandle, "DllUnregisterServer") End If
If lngFunctionAdr <> 0 Then ' ' Create an alive thread and execute the function. ' lngThreadHandle = CreateThread(ByVal 0, 0, ByVal lngFunctionAdr, ByVal 0, 0, lngThreadID)
' ' If we got the thread handle... ' If lngThreadHandle Then ' ' Wait for the thread to finish. ' blnSuccess = (WaitForSingleObject(lngThreadHandle, 10000) = WAIT_OBJECT_0)
' ' If it didn't finish... ' If Not blnSuccess Then ' ' Something happened. Close the thread. ' Call GetExitCodeThread(lngThreadHandle, lngExitCode) Call ExitThread(lngExitCode) End If
' ' Close the thread. ' Call CloseHandle(lngThreadHandle) End If End If
' ' Free the file if we loaded it. ' If lngModuleHandle Then Call FreeLibrary(lngModuleHandle)
fVBRegServer = blnSuccess
End Function
Public Function IsDLLActiveX(ByVal strDLLPath As String, Optional ByVal RaiseError As Boolean) As Boolean Dim lngHMod As Long Dim lngLastDllError As Long
lngHMod = LoadLibrary(strDLLPath)
If lngHMod = 0 Then If RaiseError Then lngLastDllError = Err.LastDllError Err.Raise 10000 + lngLastDllError, "IsDLLActiveX", "LoadLibrary-Error: " & lngLastDllError End If End If
IsDLLActiveX = Abs(CBool(GetProcAddress(lngHMod, "DllRegisterServer"))) Call FreeLibrary(lngHMod) End Function
- Når du skal unregister et ActiveX komponent gør du sådan her
If blnReturn Then Call MsgBox("Unregistration of file '" & strFile & "' succeeded!", vbInformation, "VBRegServer") Else Call MsgBox("Unregistration of file '" & strFile & "' failed!", vbCritical, "VBRegServer") End If
yay sion undrede mig også over det ikke virkede hehe
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.