?
Solved

Where is profile functions ?

Posted on 2000-01-20
8
Medium Priority
?
1,216 Views
Last Modified: 2008-03-10
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
0
Comment
Question by:ginaa
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2373239
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
 
LVL 6

Expert Comment

by:DrDelphi
ID: 2373244
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
 

Author Comment

by:ginaa
ID: 2373361
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 new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 6

Expert Comment

by:DrDelphi
ID: 2373374
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
 
LVL 3

Expert Comment

by:KhollAD
ID: 2373445
0
 
LVL 3

Expert Comment

by:KhollAD
ID: 2373473
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
 
LVL 1

Accepted Solution

by:
tirupur_selva earned 200 total points
ID: 2373481
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
 

Author Comment

by:ginaa
ID: 2387418
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

601 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