CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: please help

  1. #1
    Join Date
    Nov 1999
    Location
    California, USA
    Posts
    40

    please help

    i have been asking people for a long time, please just give me an example of puting a string in the regestry.

    PanasonicSubz

  2. #2
    Guest

    Re: please help

    Dim varSection As String
    Dim varKey As String
    Dim varSetting As String
    Dim varReturned As String
    'To Save the settings
    SaveSetting App.EXEName, varSection, varKey, varSetting
    varReturned = GetSetting(App.EXEName, varSection, varKey)

    that should work


  3. #3
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: please help

    Registry is very easy but if you have a lot of what to save to registry then you program slows down really bad.....I use .ini files as save files for example I write everything to INI
    Here is a good example:
    Declare these API: (use public if you are placing it into module and private if you are placing it on the form that you are going to call them from)

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



    1) To write to INI:

    WritePrivateProfileString SectionName, Variable, Value, FileName



    2) To read from INI:
    First you need to place this code into a module because it's public (you can change if you want to private but you will have to move it to form)
    You need this function because if you just call API strait forward then it will return integer, this function will read value as string...

    private Function ReadFromIni(SectionName as string, VariableName as string, FileName as string) as string
    Dim iReturn as string
    iReturn = string(255, Chr(0))
    ReadFromIni = Left$(iReturn, GetPrivateProfileString(SectionName, byval VariableName, "", iReturn, len(iReturn), FileName))
    End Function



    Now to read from ini to text1 (textbox)you can use this code:

    Text1 = ReadFromIni("SectionName", "Variable", "FileName")








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

Featured