(VB6)Rekisteröin shelliä käyttäen ocx ja dll -tiedostoja (regsvr32...).
Kuinka saisin tiedon, jos rekisteröintiä ei ole suoritettu? Shellihän palauttaa arvon, joka kertoo onko tehtävä suoritettu onnistuneesti.. Se ei kuitenkaan tässä tilanteessa auta, jos regsvr32:ssa tapahtuu virhe.. tai ainakin niin oletan.
Tässä API esimerkki rekisteröinnistä
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 Form_Load()
Call RegisterServer(Me.hWnd, "c:\oma.ocx", True)
End Sub
Public Function RegisterServer(hWnd As Long, DllServerPath As String, bRegister As Boolean)
On Error Resume Next
'Tarkista onko olemassa muuten kaatuu...
ie = -5
ie = GetAttr(DllServerPath)
If ie >= 0 Then
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") + " Onnistui"
Else
MsgBox IIf(bRegister = True, "Registration", "Unregistration") + " Epäonnistui"
End If
FreeLibrary lb
Else
MsgBox ("Tiedostoa ei olemassa")
End If
End FunctionAihe on jo aika vanha, joten et voi enää vastata siihen.