Solved

Simple Question on DLL

Posted on 1998-12-18
8
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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
 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

624 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