|
-
Jan 2nd, 2000, 11:11 PM
#1
Thread Starter
Member
it's about week i'm programing with vb
and i know that there are some mystirious
API functions and i know that this api is
very usefull when working with .ini files and
registry(i'm right, ain't i?)
now what i need is the sample code
for storing and loading info from api file
with explanations PLEASE
Also Where could i find good api tutorial or something like that?
-
Jan 3rd, 2000, 02:54 AM
#2
Thread Starter
Member
no no no no i mean how to use api to save,
load .ini files
-
Jan 3rd, 2000, 04:34 AM
#3
Lively Member
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As Any, ByVal lsString As Any, ByVal lplFilename As String) As Long
Public Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPriviteProfileIntA" (ByVal lpApplicationname As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
'Create a project with:
3 text box
1 appname
2 Keyname
3 txtvalue
2 command buttons
1 cmdstore
2 cmdget
Private IniFileName As String
Private Sub cmdget_Click()
Dim Temp As String * 50
Dim lpAppName As String, lpKeyName As String, lpDefault As String, lpFileName As String
Dim ret As Long
lpAppName = appname.Text
lpKeyName = Keyname.Text
lpDefault = IniFileName
lpFileName = IniFileName
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 Then
Beep
Else
txtvalue.Text = Trim(Temp)
End If
End Sub
Private Sub cmdstore_Click()
Dim lpAppName As String, lpFileName As String, lpKeyName As String, lpString As String
Dim ret As Long
lpAppName = appname.Text
lpKeyName = Keyname.Text
lpString = txtvalue.Text
lpFileName = IniFileName
ret = WritePrivateProfileString(lpAppName, lpKeyName, lpString, lpFileName)
If ret = 0 Then
Beep
End If
End Sub
Private Sub Form_Load()
IniFileName = InputBox("Which file do you want to read/edit/create?")
If IniFileName = "" Then End
End Sub
-
Jan 3rd, 2000, 06:41 AM
#4
Thread Starter
Member
Well i can say only one thing it's an alien language to me
(could anybody explain me this code, please )
-
Jan 3rd, 2000, 08:57 AM
#5
Member
Here's a sample project that deals with ini files: http://www.vb-world.net/demos/ini/
There are lots of resources available at VB-World. Just do a search for "ini files" in "All VB-World" and you will find many pages.
------------------
Mike Wellems
PowerQuery
-
Jan 3rd, 2000, 09:05 AM
#6
Hyperactive Member
nooooo! dont use ini files, use the registry - much easier and more secure.
u dont even need to call api
look up :
GetSetting
SaveSetting
in msdn.
------------------
cintel rules 
www.cintelsoftware.co.uk
-
Jan 3rd, 2000, 09:06 AM
#7
Hyperactive Member
-
Jan 3rd, 2000, 11:56 AM
#8
Junior Member
I saw this link a while back on a previous post(can't remember where)... It includes some good information.. It lists all of the API calls and gives examples of how to use them. http://skyscraper.fortunecity.com/tr...api/index.html
Hope that helps...
Mitchell Hayenga
[email protected]
-
Jan 3rd, 2000, 12:55 PM
#9
Guru
Storing and loading info from API FILE??? What about the API viewer? That will show you all of the info you need (at least to start)
-
Jan 3rd, 2000, 01:17 PM
#10
another helpful resource was originally introduced by Bruce McKinney(author of Hardcore VB); it's the win32 type library. He has since given up the development of this tlb to peet morris of TMS(The Mandelbrot Set) who, with his colleagues have taken the type library to a new level. The TLB and IDL source code(if you're in to writing type libraries) is freely downloadable here: http://www.themandelbrotset.com/html/typelib.html
...just drop it in your windows or system32 directory and then select it from projects>references in vb. it's very cool, very easy to use and encapsulates most of the win32api. I do wish however, that some of the other api's are added to the type library sometime soon.
pvb
-
Jan 3rd, 2000, 04:27 PM
#11
Hyperactive Member
Kenny: What's wrong with using ini files? Security is not an issue; windooz is not secure anyway, and secure info you want to save, you better not save with SaveSetting either. I like ini files.. their gone when the program is uninstalled, and the bigger the registry gets, the slower windooz gets (and after installing Visual Studio my registry is 10mb already...)
-
Jan 3rd, 2000, 07:30 PM
#12
Hyperactive Member
yeah, but reg is still a bit safer than using ini, and say some fool was playing around with files on a pc, and happened to delete the ini file your app needed? the person using your app wouldnt be too happy. whereas with reg, its unlikely someone qho doesnt know a lot will be bothered to go start>run>regedit
anyway u can delete your reg settings
also, it can be quite secure if u encrypt them too
------------------
cintel rules 
www.cintelsoftware.co.uk
-
Jan 3rd, 2000, 08:34 PM
#13
Thread Starter
Member
-
Jan 3rd, 2000, 11:27 PM
#14
If you want really good code,go to the
Planet Source Code. It has source code for Visual Basic, Java and C++. Their site is...
www.planet-source-code.com
-
Jan 4th, 2000, 02:56 AM
#15
Hyperactive Member
-
Jan 5th, 2000, 08:14 PM
#16
New Member
So why are you a coder then ?
Just to copy somebody else his/her code without trying to find out how the code works ?
I see a lot of people who just copy some sourcecode and complain when it doesn't work even before they checked out themselve what things a really happening.
------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|