Results 1 to 3 of 3

Thread: Visual Basic + WritePrivateProfileString

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    2

    Exclamation

    <pre>I am writing a network messaging program that will reside on our users PC<font color="#007F00">'s, but the messages (displayed in a Rich text box) will be RTF files that reside on the server. I am using the GetPrivateProfileString function, and two INI files -- one will be stored with the program, and the other will be on the users private drive mapped to when the user is logged onto our network. MY OUESTION: Using the WritePrivateProfileString function -- is there a way to use a check box to activate the function? So when the check box is enabled true, it would write a new value into the INI file. The new value would be the starting value of the next message for the user to view. This way, the program will not run unless there is a new RTF message for the user to view (and not a previously viewed). Any help will be appreciated, **Thanks**</font></pre>

  2. #2
    Guest
    Code:
    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
    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
    
    Public Function readini(strsection As String, strkey As String, strfullpath As String) As String
       Dim strbuffer As String
       Let strbuffer$ = String$(750, Chr$(0&))
       Let readini$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
    End Function
    
    Public Sub writeini(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
        Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
    End Sub
    
    Call writeini("Check.ini", "Checked", "" & Check1.Value & "", "C:\Check.ini")
    
    Check1.Value = "" & readini("Check.ini", "Checked", "C:\Check.ini")
    
    If Check1.Value = 1 Then
    'code
    End If
    [Edited by Matthew Gates on 07-27-2000 at 05:49 PM]

  3. #3
    Addicted Member
    Join Date
    Apr 2000
    Posts
    215
    there is also a project demo on here in the demos section if you want to download that.

    http://www.vb-world.net/demos/ini/

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