• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

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
0
CraigLazar
Asked:
CraigLazar
1 Solution
 
MirkwoodCommented:
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
0
 
sbmcCommented:
Yes you do. VB3 is a 16 bit app
0
 
CraigLazarAuthor Commented:
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
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
mdouganCommented:
Whoa, hold on a sec.

GetPrivateProfileString is one of the Windows API functions.  That means that it is "built into Windows" itself.  In other words, you are calling a function that is part of the Windows operating system.  The Windows operating system is made up of at least 3 main DLLs,  KERNEL.DLL, GDI.EXE and USER.EXE (even though they have an exe extension, you can call functions inside of them like a DLL).  If you have an operating system that supports 16-bit  VB3 (like Windows 95) then you already have the KERNEL.DLL file.  

Now, if you want to develop this in VB5 or greater, which only supports 32-bit, then you have to change all of the Windows API declaration statements to point to the 32-bit versions of those same functions.  Most of the 16-bit APIs (but not all) have counterparts in the 32-bit versions.  The difference is that they usually have an A on the end of the name ( like "GetPrivateProfileStringA" ), but the declare usually gives it an alias of the original name ("GetPrivateProfileString" ), and they point to the 32-bit version of the Windows DLL (kernel32.dll).  But in any event, you never have to worry about getting a copy of these DLLs, they are part of Windows.

MD


0
 
CraigLazarAuthor Commented:
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
0
 
CraigLazarAuthor Commented:
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
0
 
mdouganCommented:
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
0
 
CraigLazarAuthor Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now