Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-02

reading windows registry

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Charl van Jaarsveldt

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.
Michael Van Canneyt
to Charl van Jaarsveldt
Charl van Jaarsveldt wrote 5 lines
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.

I suggest using the TRegistry class in the registry unit. Your code would be reduced to:

S:=Paramstr(1);
With TRegistry.Create do
  try
    RootKey:=HKEY_LOCAL_MACHINE;
    If OpenKeyReadOnly('Software\ODBC\ODBC.INI\ODBC Data Sources') then
      If ValueExists(S) then
        S:=ReadString(S); // Or whatever it is. ReadInteger/ReadBool
  finally
    Free;
  end;

Michael.

Charl van Jaarsveldt
to Charl van Jaarsveldt: Hallo. I have this little program to get te info of a certain ODBC entry n the registry,…

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 53 lines
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 - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Michael Van Canneyt
to JK
JK wrote
Hi All, is there a way to read/write cookies and use sessions in FP? I can't find it in cgiapp.

There is currently no way, but it should be easy to add this. Setting a cookie is just emitting the correct header. I'm not sure about retrieving it, though. I don't know how the headers get passed to a cgi app, but that should be easy to find out.

Michael.

Jeff Pohlmeyer

There is a cookies unit listed under " Contributed Units -> Internet " on the freepascal website, but unfortunately, the link seems be broken. ( Or at least down right now. )

I had a copy laying around, so I uploaded it to my personal homepage:

http://houston.quik.com/jkp/cookies.zip

Please note that I did NOT write this unit, and I have NOT tested it.

But it looks like it *might* be a starting place...

- Jeff

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html

Unknown author
to Jeff Pohlmeyer
Jeff Pohlmeyer wrote 12 lines
There is a cookies unit listed under " Contributed Units -> Internet " on the freepascal website, but unfortunately, the link seems be broken. ( Or at least down right now. ) I had a copy laying around, so I uploaded it to my personal homepage: http://houston.quik.com/jkp/cookies.zip Please note that I did NOT write this unit, and I have NOT tested it. But it looks like it *might* be a starting place...

Thanks,

I will try to update the existing CGI units in FPC based on what I find here.

Michael.