FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ReqQueryValue behaviour
Posts: 25
Joined: Sun Oct 23, 2005 09:58 PM
ReqQueryValue behaviour
Posted: Mon Feb 06, 2006 06: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

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ReqQueryValue behaviour
Posted: Mon Feb 06, 2006 07:02 PM

Because the value returned is a zero-terminated string.

EMG

Continue the discussion