Results 1 to 3 of 3

Thread: Registry doesn't need crap!

  1. #1

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266

    Angry

    My VB program writes garbage to the windows registry.
    Shouldn't do this.

    Can anyone please look at my code, and tell me what's wrong?
    (Asume constants and APIs are already declared...)


    Public Sub Main()
    Dim KeyHandle As Long, result As Long, _
    StrDir As String * MAX_PATH, _
    NewStrDir as String

    Result = GetSystemDirectory(StrDir, MAX_PATH)
    NewStrDir = Left(StrDir, Result) & "\server.exe"
    Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0&, KEY_ALL_ACCESS, KeyHandle)
    Result = RegSetValueEx(KeyHandle, "myserver", 0, REG_SZ, NewStrDir, CLng(Len(NewStrDir) + 1))
    Result = RegCloseKey(KeyHandle)
    Load frmMainServer
    ' Bla Bla Bla Bla
    End Sub


    Is it something to do with Unicode and ANSI?

    I will be using my program on Windows NT and Windows 95, 98 also.
    These include from 95 - Millennium, NT 4.0 - 2000.

    thnx 4 helping.

    (sorry, for the format. 'twas quick) 8-)
    jovton

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    might have to do, you could try convert it from unicode:

    NewStrDir =strconv(NewStrDir ,vbfromunicode)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266

    Thumbs up

    thanx kedaman.

    but i found out my real problem.

    where i said

    Result = RegSetValueEx(KeyHandle, "myserver", 0, REG_SZ, NewStrDir, CLng(Len(NewStrDir) + 1))

    It should have been

    Result = RegSetValueEx(KeyHandle, "myserver", 0, REG_SZ, ByVal NewStrDir, CLng(Len(NewStrDir) + 1))

    just needed a ByVal.

    hope you other guys not run into same problem.

    thanx again, kedman.
    jovton

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