Link to home
Start Free TrialLog in
Avatar of CraigLazar
CraigLazar

asked on

Simple Question on DLL

Hi
I am using VB3 and i need to use the getprivateprofilestring dll
but i think it is not working becase in my declarations for vb3 it is looking for the kernel.dll
i am using the same function in vb5 which it's declare statement looks at kernel32
must i get a copy of kernel.dll load it into windows ?
thanx
C
Avatar of Mirkwood
Mirkwood

The declare
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

And no, you don't need kernel.dll. Only 16 bit apps do
Yes you do. VB3 is a 16 bit app
Avatar of CraigLazar

ASKER

Hi Mirkwood
Thanx for your answer but i am using it in vb 3 which is a 16-bit app so do i need the kernel.dll file ?
and were can i get it ?

thanx Craig
ASKER CERTIFIED SOLUTION
Avatar of mdougan
mdougan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Mdougan
Thanx for the tip
I am Developing this piece of software for a bank . Long story short 1/2 of it is in VB3 and the rest in VB5
the reason why i am using VB3 is because i am using some 16-bit Dll's which were created in assembler language . So it was easier for me to use VB3 than to recompile those 16 -bit Dll's .
So i have had a look on my pc and i do not have kernel.dll
now in vb 3 the declare statement seems to be looking fro "Kernel"
I am using exactly the same function in vb 5 in the declare statement it is "kernel32" so i tried changing it in the vb3 app but it does not work
Now if i leave it as "Kernel" in vb3 then it keeps giving me my default string (u know if the profile string does not find anything in the specified fiel . I have made sure of the file name , the heading ect still gives me hassles . So i thought i needed the Kernel.dll on my pc so hopefully this procedure would work
I would appreciate any more tips or Suggestions
Thanx Allot Craig
Hi Mdougan
Thanx for the tip
I am Developing this piece of software for a bank . Long story short 1/2 of it is in VB3 and the rest in VB5
the reason why i am using VB3 is because i am using some 16-bit Dll's which were created in assembler language . So it was easier for me to use VB3 than to recompile those 16 -bit Dll's .
So i have had a look on my pc and i do not have kernel.dll
now in vb 3 the declare statement seems to be looking fro "Kernel"
I am using exactly the same function in vb 5 in the declare statement it is "kernel32" so i tried changing it in the vb3 app but it does not work
Now if i leave it as "Kernel" in vb3 then it keeps giving me my default string (u know if the profile string does not find anything in the specified fiel . I have made sure of the file name , the heading ect still gives me hassles . So i thought i needed the Kernel.dll on my pc so hopefully this procedure would work
I would appreciate any more tips or Suggestions
Thanx Allot Craig
If you are running Windows 95 or Windows NT you will not find a file called Kernel.DLL (sometimes the declare statements leave off the DLL).  Again, don't worry about the location of that file, since Windows will handle it.  Just make sure that in the VB3 program you're pointing to KERNEL, and in the VB5 program you're pointing to KERNEL32.

The fact that you are not getting a runtime error on the call to GetPrivateProfileString means that the system is finding the appropriate 16-bit Windows API function.

Now, as for getting the default value all of the time.  There are two things to check.  One is the declaration statement itself.  I think the declare statement as copied from the VB Win API help file is wrong.  Make sure that all of the parameters that are defined in the declaration statement have the word ByVal in front of it.  Also, I change the second parameter, lpKeyName, to "As Any" instead of "As String". I believe that this will correct your problem.  If not...Secondly, I've also had a lot of trouble with the same thing, and it sometimes boiled down to the fact that GetPrivateProfileString could not find my INI file.  If you want to keep your INI file in the Windows directory, then you can use the name of INI file in the GetPrivateProfileString function call without a path.  However, if you plan to have the INI file in the directory where your exe is, then make sure to have the full path and file name to the INI file in your GetPrivateProfileString function call.  I use the App.Path as you never know where the user will install your program.  If you try this and still have trouble, include a copy of your call to GetPrivateProfileString, and I'll see if I see anything else.

Cheers!

MD
Man Mdougan thanx very much for your help , i just copied the declare string out the vb3 api text viewer and u were write the byval was missing on keyname

thanx
Craig