Results 1 to 16 of 16

Thread: Question for vb gurus

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Vilnius, Lithuania
    Posts
    50

    Post

    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?

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Vilnius, Lithuania
    Posts
    50

    Post

    no no no no i mean how to use api to save,
    load .ini files

  3. #3
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87

    Post

    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

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Vilnius, Lithuania
    Posts
    50

    Post

    Well i can say only one thing it's an alien language to me

    (could anybody explain me this code, please )

  5. #5
    Member
    Join Date
    Nov 1999
    Location
    Kansas, USA
    Posts
    58

    Post

    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

  6. #6
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355

    Post

    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

  7. #7
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi,casparas.
    Here is a link: http://visualbasic.miningco.com/libr...a121998.htm?id

    Larisa

  8. #8
    Junior Member
    Join Date
    Jan 2000
    Location
    Bryan, Texas
    Posts
    27

    Post

    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]

  9. #9
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    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)

  10. #10
    Guest

    Post

    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

  11. #11
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

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

  12. #12
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355

    Post

    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

  13. #13

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Vilnius, Lithuania
    Posts
    50

    Post

    Thanx everyone

    -Casparas


  14. #14
    Guest

    Post

    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


  15. #15
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355

    Post

    except a lot of the code there doesnt work
    and u have to spend 1/2hr fixing it

    ------------------
    cintel rules
    www.cintelsoftware.co.uk

  16. #16
    New Member
    Join Date
    Nov 1999
    Location
    l
    Posts
    13

    Post

    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
  •  



Click Here to Expand Forum to Full Width