ReqQueryValue behaviour

ReqQueryValue behaviour

Postby Vytas » Mon Feb 06, 2006 6:47 pm

Hi

When I use RegQueryValue() to get the string to run an executable to which I wish to pass a parameter why must I remove the last character on the return value?

In the following sample program. After the first call to WordPad no file is opened, however on the second call the file opens as expected.

Thanks,

Vytas

// Managing Register services from FiveWin

#ifndef __XPP__
#define HKEY_CLASSES_ROOT 2147483648
#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650
#define HKEY_USERS 2147483651
#define HKEY_PERFORMANCE_DATA 2147483652
#define HKEY_CURRENT_CONFIG 2147483653
#define HKEY_DYN_DATA 2147483654
#else
#define HKEY_CLASSES_ROOT 1
#define HKEY_CURRENT_USER 2
#define HKEY_LOCAL_MACHINE 3
#define HKEY_USERS 4
#define HKEY_PERFORMANCE_DATA 5
#define HKEY_CURRENT_CONFIG 6
#define HKEY_DYN_DATA 7
#endif

//---------------------------------------------------------------------------//

function Main()

local nHandle, cValue

if RegOpenKey( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths", @nHandle ) == 0

RegQueryValue( nHandle, "WordPad.exe", @cValue )

MsgInfo( cValue )

WaitRun(cValue + " testreg.prg")
WaitRun(SUBSTR(cValue,1,(LEN(cValue)-1)) + " testreg.prg")

RegCloseKey( nHandle )
else
MsgAlert( "Can't open this key" )
endif

return nil

//---------------------------------------------------------------------------//

procedure AppSys // XBase++ requirement

return

//---------------------------------------------------------------------------//
Vytas
 
Posts: 25
Joined: Sun Oct 23, 2005 9:58 pm

Re: ReqQueryValue behaviour

Postby Enrico Maria Giordano » Mon Feb 06, 2006 7:02 pm

Because the value returned is a zero-terminated string.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8410
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 147 guests