Click to See Complete Forum and Search --> : Reading from the Registry in Win2K
DanniDin
April 1st, 2001, 09:10 AM
Hi
I'm Using the Registry Example from http://www.allapi.net/api/api241.php
It Works Great in Win98 But the Line that is Used to Remove the Unnecessary chr$(0)'s:
RegQueryStringValue = Left$(strBuf, InStr(1, strBuf, Chr$(0)) - 1)
Doesn't Work in Win2K and Because I Don't Have Win2K Installed on My PC I Can't Fix it.
Does Anyone Have a Working Code for Win2K?
Thanks in Advance,
Danni.
DanniDin
April 2nd, 2001, 05:24 AM
Can the Following Line Work ?
RegQueryStringValue = Left(strBuf, lDataBufSize - 1)
Does strBuf Always Have Only One Extra Char ?
Danni.
Johnny101
April 2nd, 2001, 02:33 PM
i think all strings that are returned from API calls are null terminated (like in C). so i always just get rid of the last character and then trim the result to get a clean string result.
hope this helps,
john
John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org
DanniDin
April 5th, 2001, 05:37 AM
The Problem is How to Get Rid of the Last Character in Win2K without Getting Runtime Errors.
Danni.
Johnny101
April 5th, 2001, 09:06 AM
The null character will always be the last character - so just hack off the last character:
strBuff = Trim(Left(strBuff, len(strBuff) - 1))
john
John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org
DanniDin
April 13th, 2001, 06:13 AM
This is the Only Code that Works for Me (On Win2K):
'
'
'
If lResult = 0 then
RegQueryStringValue = StripTerminator(strBuf)
End If
'
'
'
Function StripTerminator(byval strBuf as string) as string
Dim NullPos as Long
NullPos = InStr(1, strBuf, vbNullChar)
If NullPos > 0 then _
StripTerminator = Left$(strBuf, NullPos - 1) else _
StripTerminator = strBuf
End Function
Thanks for Your Answer!
Danni.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.