Solved

Simple Question on DLL

Posted on 1998-12-18
8
242 Views
Last Modified: 2008-03-10
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
Comment
Question by:CraigLazar
8 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1451251
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
 
LVL 2

Expert Comment

by:sbmc
ID: 1451252
Yes you do. VB3 is a 16 bit app
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 1451253
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
 
LVL 18

Accepted Solution

by:
mdougan earned 70 total points
ID: 1451254
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Author Comment

by:CraigLazar
ID: 1451255
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
 
LVL 4

Author Comment

by:CraigLazar
ID: 1451256
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
 
LVL 18

Expert Comment

by:mdougan
ID: 1451257
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
 
LVL 4

Author Comment

by:CraigLazar
ID: 1451258
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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now