library DllDemo; uses SysUtils,Classes, Registry, Windows; //************************************************************************ // DLL call to read a Registry value; it will be passed back as a string // Inputs: // str Key: the Registry Key to use (i.e. 'Software\AETO\DIT-AUTOMATION') // str Sec: the section in the Registry to use (i.e. 'Values') // str Valu: the specific string key to use (i.e. 'Release Date') // Output: // str: If passed: The string expected // If Failed: The error message (Starts 'ReadRegValue Exception: ') //************************************************************************ Function ReadRegValue(Key:PChar;Sec:PChar;Valu:PChar):PChar; stdcall; export; Var INI: TRegIniFile; // Object to encapsulate Registry operations S: String; Begin INI := TRegIniFile.Create(Key); // Instantiate the object try try S := INI.ReadString(String(Sec),String(Valu),''); // Read the registry GetMem(Result, Length(S) + 1); // Allocate heap for it StrCopy(Result, PChar(S)); // set the return value except On E: Exception do begin // In case of error S := 'ReadRegValue Exception: ' + E.Message; // Pick up the message GetMem(Result, Length(S) + 1); // and return it to StrCopy(Result, PChar(S)); // caller End; End; Finally Ini.Free; // Free the object End; End; //************************************************************************ // DLL call to write a value to the Registry; it will be written as a string // Inputs: // str Key: the Registry Key to use (i.e. 'Software\AETO\DIT-AUTOMATION') // str Sec: the section in the Registry to use (i.e. 'Values') // str Valu: the specific string key to use (i.e. 'Release Date') // str Inp: the value to set Valu to // Output: // str: If passed: '0' // If Failed: The error message (Starts 'WriteRegValue Exception: ') //************************************************************************ Function WriteRegValue(Key:PChar;Sec:PChar;Valu:PChar;Inp:PChar):PChar;stdcall;export; Var INI: TRegIniFile; // Object to encapsulate Registry operations S: String; Begin INI := TRegIniFile.Create(Key); // Instantiate the object try try INI.WriteString(String(Sec), // Write to the Registry String(Valu), String(Inp)); S := '0'; GetMem(Result, Length(S) + 1); // If successful, return a '0' StrCopy(Result, PChar(S)); except On E: Exception do begin S := 'WriteRegValue Exception: ' // If unsuccessful, return the + E.Message; // error message thrown by the GetMem(Result, Length(S) + 1); // the OS. StrCopy(Result, PChar(S)); End; End; Finally Ini.Free; // Free the object End; End; //************************************************************************ // Function to return a Boolean value based on the status of the window // Input: // hndl: Handle of the window to be checked // Output: // integer: TRUE (1) if the window is maximized // integer: FALSE (0) if the window is not maximized //************************************************************************ function isWindowMax(hndl: Integer): integer; stdCall; export; begin If (isZoomed(hndl)) then Result := 1 else Result := 0; end; exports ReadRegValue, WriteRegValue, isWindowMax; begin end.