Where is profile functions ?

Where is the profile function in vb6?
These functions, GetPrivateProfileInt, WritePrivateProfileInt,...
doesn't work in vb6, and can't be found in online help.

Ginaa
ginaaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RuchiCommented:
This is from the web. If you want the code, let me know ,and I will place it in this post.


The magic of the Windows 3x INI files eluded most until the Get/WriteProfileString and Get/WritePrivateProfileString APIs were discovered.  

Windows actually provides a number of "Profile" APIs available to the developer:

API
  File  Description
GetPrivateProfileInt  user.ini  retrieves an integer associated with a key in the specified section of the given initialization file.
GetPrivateProfileSection  user.ini  retrieves all of the keys and values for the specified section from an initialization file.
Windows 95: The specified profile section must not exceed 32K.
Windows NT/2000: The specified profile section has no size limit.
GetPrivateProfileSectionNames  user.ini  retrieves the names of all sections in an initialization file.
GetPrivateProfileString  user.ini  retrieves a string from the specified section in an initialization file
GetPrivateProfileStruct  user.ini  retrieves the data associated with the specified key in the given section of an initialization file. As it retrieves the data, the function calculates a checksum and compares it with the checksum calculated by the WritePrivateProfileStruct function when the data was added to the file.  
GetProfileInt  win.ini  retrieves an integer from the specified key name in the given section of the WIN.INI file.
GetProfileSection  win.ini  retrieves all of the keys and values for the specified section of the WIN.INI file.  
GetProfileString  win.ini  retrieves the string associated with the specified key in the given section of the WIN.INI file.
     
WritePrivateProfileSection  user.ini  replaces the keys and values under the specified section in an initialization file.
WritePrivateProfileString  user.ini  copies a string into the specified section of the specified initialization file.
WritePrivateProfileStruct    copies data into the specified key in the given section of an initialization file. As it copies the data, the function calculates a checksum and appends it to the end of the data. The GetPrivateProfileStruct function uses the checksum to ensure the integrity of the data.
WriteProfileSection  win.ini  replaces the contents of the specified section in the WIN.INI file with the specified keys and values.
WriteProfileString  win.ini  copies a string into the specified section of the WIN.INI file.

References to "user.ini" indicate that the API is for use with application-specific files. The file can have any name, but it remains the custom is to name it the same as the application to facilitate easier locating should it need editing or removal. And historically, in Win3x days, Microsoft had encouraged saving application-specific ini files in the system's Windows directory. Common practice nowadays is to use the application's folder.

Despite the number of possible APIs available, most applications get away with using only two - GetPrivateProfileString and WritePrivateProfileString. Regardless, all the APIs share a commonality in the declaration of the APIs and the method of passing/receiving data using any given one.

This demo starts out by covering the basics - using GetPrivateProfileString and WritePrivateProfileString to read/write data to a private ini file. And long with saving and reading, we'll also cover deleting specific items, and entire sections. In VBnet fashion, there is more commenting than code; you'll be pleasantly surprised how little code is really necessary to add this functionality to your apps.

Subsequent demos will build on the same BAS module, providing enhanced functionality. And while there now exists APIs to handle entire sections at a time (something introduced with Win9x), as a learning process those will be skipped in favor of using just the same two APIs to do everything we need.

0
DrDelphiCommented:
There isn't a WritePrivateProfileInt, but there is a WritePrivateProfileString, which is what I suspect you mean.


Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
0
ginaaAuthor Commented:
Sorry,
I am not sure I understand or not.
You mean these functions are provided in windows environment,
so I still can use these APIs to do profile in VB6, right?
Now I can not find the usage in online help,
So, can you tell me where to find or you can provide samples for
all APIs.

Ginaa
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

DrDelphiCommented:
There is a utility that shipped with VB until version 5 (sorry, I don't have 6) called "API text viewer" ... you can find the API declarations there. Otherwise,I am pretty sure that M$'s Knowledge base will have them. The thing to remeber is that API is not VB version specific ... it's not even VB specific. I am a Delphi programmer and I use API more thanDElphi most of the time.
0
KhollADCommented:
In the Api sample, change the api declarations to :

Declare Function GetProfileInt Lib "kernel32" Alias "GetProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Long) As Long

Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long

Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long

Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long

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

Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long


0
tirupur_selvaCommented:
The API Text Viewer is also available with the VB6. In that also, you can just get the declaration part of the function. and not the constants that are essential. For a brief description of each of the API functions you need to install MSDN6 or MSDN6a which comes with Microsoft Visual Studio 97 or 6.
In it, you can get a brief description of the parameters and the constants to be used.
Hope this would be useful
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ginaaAuthor Commented:
I found some description for those API in MSDN6.
But it doesn't tell me how to declare and use in VB. And it seem all help are combine togather. So if I  request online help in VB, it will show many other description or another language.

Ginaa
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.