[fpc-pascal]reading windows registry
Charl van Jaarsveldt
charlvj at ict.om.org
Tue Feb 3 10:49:22 CET 2004
Hi
I found my mistake: I didn't give the size of the buffer in variable bl.
It now works.
Peace.
Charl
Charl van Jaarsveldt wrote:
> Hallo.
>
> I have this little program to get te info of a certain ODBC entry n
> the registry, but it doesn't work and I am at a loss. I admit, I
> haven't done too much win32 stuff before. Any ideas and help would be
> appreciated.
>
> Peace.
> Charl
>
>
> Here is the program: (please see comments at the end)
>
> Program RegTest01;
>
> Uses
> Crt, windows;
>
> Var
> key : HKEY;
> pt : array[0..80] of char;
> bl, ret : DWORD;
> s : string;
>
> Begin
> If paramCount <> 1 Then
> Begin
> writeln( 'Usage:' );
> writeln( ' ', paramstr( 0 ), ' <datasource name>' );
> halt( 0 );
> End;
> s := paramStr( 1 );
> RegOpenKeyEx( HKEY_LOCAL_MACHINE,
> 'Software\ODBC\ODBC.INI\ODBC Data Sources',
> 0, KEY_QUERY_VALUE, key );
> ret := RegQueryValueEx( key, @s[1], nil, nil, @pt, @bl );
> RegCloseKey( key );
>
> {Now, when the datasource is valid, bl = 0 and ret = 2 - not sure
> what the return value 2 means :-(
> If the datasource IS valid, I get bl = size of the value
> (correctly) pt = '', and ret = 234 (ERROR_MORE_DATA)
> I have tried with really BIG buffers and I get the same result}
>
> writeln( 'pt = ', pt, ' bl = ', bl );
> writeln( 'return: ', ret );
> End.
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list