|
-
Nov 24th, 2000, 07:48 AM
#1
Thread Starter
Hyperactive Member
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-)
-
Nov 24th, 2000, 12:34 PM
#2
transcendental analytic
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.
-
Nov 24th, 2000, 02:48 PM
#3
Thread Starter
Hyperactive Member
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.
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
|