parker6469
06-19-2003, 03:33 PM
I recently wrote a small application that uses the "Save" common dialog. I want this application to run on Win NT 4.0, but when I try to run it, I get an error stating:
Component 'COMDLG32.OCX" or one of its dependencies not correctly registered: a file is missing or invalid
I want to create an installation for my program to 'register' this file, but I really do not know where to begin. I have read several posts on here about install programs and downloaded Inno Setup Compiler. I am not sure what exactly to write in the script to register this file.
I also believe that VB came with InstallShield, but I have not tried using that yet.
Does anyone know how I can use either Inno or InstallShield to install my program and correctly register the comdlg32.ocx file?
Thanks
vbfan
06-20-2003, 05:33 AM
Ok the easiest Setupapp is P&DW it comes with VB( you only have to click some buttons not more).
But InnoSetup is the better one you can set more things, for a little tutor about using InnoSetup look here (http://www.visualbasicforum.com/showthread.php?threadid=22267&highlight=inno+setup).
Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Public Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Public 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
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Public Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
'Use this function to register ActiveX file. Flag must be true to register, false otherwise
Public Function RegDll(ByVal File As String, ByVal Flag As Boolean) As Long
On Error Resume Next
Dim lLib As Long
Dim lpDLLEntryPoint As Long
Dim lpThreadID As Long
Dim lpExitCode As Long
Dim mThread
Dim mResult As Long
'Map library into address space of calling proccess
lLib = LoadLibrary(File)
'If llib = 0 Then no file or this is regular dll
If lLib = 0 Then
RegDll = 0
Exit Function
End If
Select Case Flag
Case True 'Register
lpDLLEntryPoint = GetProcAddress(lLib, "DLLRegisterServer")
Case False 'Unregister
lpDLLEntryPoint = GetProcAddress(lLib, "DLLUnregisterServer")
End Select
If lpDLLEntryPoint = vbNull Then
RegDll = 0
Exit Function
End If
mThread = CreateThread(ByVal 0, 0, ByVal lpDLLEntryPoint, ByVal 0, 0, lpThreadID)
If mThread = 0 Then
RegDll = 0
Exit Function
End If
mResult = WaitForSingleObject(mThread, 10000)
If mResult = 0 Then
RegDll = 0
Exit Function
End If
CloseHandle mThread
FreeLibrary lLib
RegDll = 1
End Function
'******************
'Code explanation:
'1. Map library into you process's address space (load it)
'2. If you need to register, find function 'DllRegisterServer' and get pointer to it
'2.1 If you need to unregister, find function 'DllUnregisterServer' and get a pointer to it
'3. Dereference pointer. It's impossible to do in VB, so we call CreateThread API and pass it address of the function (just like it's in standard module)
'4. Wait until the thread is finished
'5. When it is, free space occupied by the library (unload it)
'*******************