pahmn
asked on
Call a procedure in VB from a standard DLL(not ActiveX)
Hi All
I want to call a procedure in VB from a standard DLL(not ActiveX) .
I am using LoadLibrary/GetProcAddress API call to load the DLL and setting a pointer to the function. I am totally new to this, and I am unable to figure out how to pass the reqired parameters to make the call.
I need to be able to make a call like :
INT IGSearch(Address,City, State,Zip, StateCode,CountyCode, MSACode,TrackBNA)
Please send me the exact way to do it.
Thanks
Pahmn
I want to call a procedure in VB from a standard DLL(not ActiveX) .
I am using LoadLibrary/GetProcAddress
I need to be able to make a call like :
INT IGSearch(Address,City, State,Zip, StateCode,CountyCode, MSACode,TrackBNA)
Please send me the exact way to do it.
Thanks
Pahmn
Is it a 32-bit dll?
If so, why don't you use standard "declare function....."?
If so, why don't you use standard "declare function....."?
ASKER
I have no idea on the standard declare procedure. Please guide me by sending me a sample for my case.
is it a COM dll?
If not, something like:
private declare function IGSearch lib "igsearch" (Address,City, State,Zip, StateCode,CountyCode, MSACode,TrackBNA) as integer
I assumed that dll is called "igsearch", replace with a valid name.
What is strange to me is return value integer, are you sure that it is a 32-bit dll?
I dont know data types of parameters so you must to replace accordingly.
This is an example of standard declare procedure for a give api:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long)
As Long
If not, something like:
private declare function IGSearch lib "igsearch" (Address,City, State,Zip, StateCode,CountyCode, MSACode,TrackBNA) as integer
I assumed that dll is called "igsearch", replace with a valid name.
What is strange to me is return value integer, are you sure that it is a 32-bit dll?
I dont know data types of parameters so you must to replace accordingly.
This is an example of standard declare procedure for a give api:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long)
As Long
ASKER
Is there some way to know that whether it is a 32-bit DLL or not. I was given this DLL by a company to use. I do not have its details...
Do you have Dependancy Walker (from visual studio)?
If so, open that dll with it.
Optionally, you could use quickview to see it.
If so, open that dll with it.
Optionally, you could use quickview to see it.
ASKER
Which quickview? I cannot even add the dll in the references in VB, so I am not sure how would I open it in a Dependancy walker...
I am totally new to this kind of DLLS. I just make and use ActiveX DLLS...
I am totally new to this kind of DLLS. I just make and use ActiveX DLLS...
ASKER
I have the following details about the parameters:
INT IGSearch(LPCTSTR lpAddress, lpCity, lpState, lpZipCode,
lpStateCode, lpCountyCode, lpMSACode, lpTractBNA)
Arguments
lpAddress, lpCity, lpState, lpZipCode
Specifies the address to be given as input.
lpStateCode, lpCountyCode, lpMSACode, lpTractBNA
Specifies output values to be filled-in by the Function.
I do not understand how to use these parameters as input and output?
INT IGSearch(LPCTSTR lpAddress, lpCity, lpState, lpZipCode,
lpStateCode, lpCountyCode, lpMSACode, lpTractBNA)
Arguments
lpAddress, lpCity, lpState, lpZipCode
Specifies the address to be given as input.
lpStateCode, lpCountyCode, lpMSACode, lpTractBNA
Specifies output values to be filled-in by the Function.
I do not understand how to use these parameters as input and output?
Give me a mail and i could provide you with dependancy walker.
ASKER
Please mail me at miya5656@yahoo.com
Done.
ASKER
Thanks Richie
It is a 32-bit DLL.
When I declare the DLL and try to use it, it gives me an Entry point not found error...
I think this is a fairly common error with this kind of DLLs, but how can this be resolved.
Pahmn
It is a 32-bit DLL.
When I declare the DLL and try to use it, it gives me an Entry point not found error...
I think this is a fairly common error with this kind of DLLs, but how can this be resolved.
Pahmn
Well, are you sure that is the real name for function?
You could check it with Dependancy walker also (it list all exported/imported function that uses)
You could check it with Dependancy walker also (it list all exported/imported function that uses)
ASKER
Yes, I checked it in the dependency walker, and also I have the documentation for the DLL, which lists the name of the function.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Richie, I am posting my exact code. There are two functions to be called prior to calling the IGSearch. When I am calling the first function IGSetupGetPath , I should be getting the path in IGPath, which I am not getting. And hence, the subsequent calls fail. Though I am getting the value of Buffer Size, I do not get the exact path....
Any ideas???
========================== ========== ========== ========== ==
Private Declare Function IGsearch Lib "C:\Winnt\system32\IGSyste m.dll" (Address As String, City As String, State As String, Zip As String, StateCode As String, CountyCode As String, MSACode As String, TrackBNA As String) As Integer
Private Declare Function IGSetupGetPath Lib "C:\Winnt\system32\IGSetup .dll" (PathBuffer As String, BuffSize As Integer, ForceDisp As Boolean) As Boolean
Private Declare Function IGSystemSetPath Lib "C:\Winnt\system32\IGSyste m.dll" (IGPath As String) As Boolean
Private Sub Form_Load()
dim flgPath as Boolean
dim flgPath1 as Boolean
dim test as Integer
Dim IGPath As String
Dim PSize As Integer
flgPath = IGSetupGetPath(IGPath, PSize, True)
flgPath1 = IGSystemSetPath(IGPath)
test = IGsearch("2 Ada", "Irvine", "CA", "92618", StateCode, CountyCode, MSACode, TrackBNA)
end sub
Any ideas???
==========================
Private Declare Function IGsearch Lib "C:\Winnt\system32\IGSyste
Private Declare Function IGSetupGetPath Lib "C:\Winnt\system32\IGSetup
Private Declare Function IGSystemSetPath Lib "C:\Winnt\system32\IGSyste
Private Sub Form_Load()
dim flgPath as Boolean
dim flgPath1 as Boolean
dim test as Integer
Dim IGPath As String
Dim PSize As Integer
flgPath = IGSetupGetPath(IGPath, PSize, True)
flgPath1 = IGSystemSetPath(IGPath)
test = IGsearch("2 Ada", "Irvine", "CA", "92618", StateCode, CountyCode, MSACode, TrackBNA)
end sub
Private Declare Function IGsearch Lib "IGSystem" (Address As String, City As String,
State As String, Zip As String, StateCode As String, CountyCode As String, MSACode As String, TrackBNA
As String) As Integer
Private Declare Function IGSetupGetPath Lib "IGSetup" (PathBuffer As String, BuffSize
As Integer, ForceDisp As Boolean) As Boolean
Private Declare Function IGSystemSetPath Lib "IGSystem" (IGPath As String) As
Boolean
Try passing arg ByVal. It appears like a trial and error way of life but ....
Could you send me the dll?
State As String, Zip As String, StateCode As String, CountyCode As String, MSACode As String, TrackBNA
As String) As Integer
Private Declare Function IGSetupGetPath Lib "IGSetup" (PathBuffer As String, BuffSize
As Integer, ForceDisp As Boolean) As Boolean
Private Declare Function IGSystemSetPath Lib "IGSystem" (IGPath As String) As
Boolean
Try passing arg ByVal. It appears like a trial and error way of life but ....
Could you send me the dll?
ASKER
Richie
Thanks for all your help.
It finally started working after passing args ByVal, and filling the variables with spaces prior to making the call. But the strange thing is that sometimes it works, and sometimes it doesn't. Is there a way to set this DLL to nothing after the job is done?
Thanks again
Pahmn
Thanks for all your help.
It finally started working after passing args ByVal, and filling the variables with spaces prior to making the call. But the strange thing is that sometimes it works, and sometimes it doesn't. Is there a way to set this DLL to nothing after the job is done?
Thanks again
Pahmn
That dll is not an object so we can't set it to "nothing". If you are using loadlibrary instead of "declare" way, it could be released from memory when it would be longer needed.
ASKER
I had tried LoadLibrary, but was unable to figure out how to call the functions from it. If we stick to the Declare method, when does the dll get released from the memory?
Thanks
Pahmn
Thanks
Pahmn
that's a good question by itself!!!
I think that the life of that dll in memory should be in scope of calling thread. I mean, if you use that function inside an other fucntion, dll should be released from memory after you reached en function statement (or a little after that).
I think that the life of that dll in memory should be in scope of calling thread. I mean, if you use that function inside an other fucntion, dll should be released from memory after you reached en function statement (or a little after that).
Thanks for "A" grade!
ASKER