library DetectDotNet; { Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. } uses SysUtils, Classes, Registry, WinTypes, Dialogs; {$R *.res} const strDotNet35RegistryPath = 'Software\Microsoft\NET Framework Setup\NDP\v3.5'; const strDotNet30RegistryPath = 'Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup'; const strDotNet20RegistryPath = 'Software\Microsoft\NET Framework Setup\NDP\v2.0.50727'; function ReadRegEntry(strSubKey, strValueName: string): string; var Key: HKey; Buffer: array[0..255] of char; Size: cardinal; begin Result := 'ERROR'; Size := SizeOf(Buffer); if RegOpenKeyEx(HKEY_LOCAL_MACHINE, PChar(strSubKey), 0, KEY_READ, Key) = ERROR_SUCCESS then if RegQueryValueEx(Key,PChar(strValueName),nil,nil, @Buffer,@Size) = ERROR_SUCCESS then Result := Buffer; RegCloseKey(Key); end; function TI_MinimumDotNetInstalled: Integer; CDecl; var strRegValue: string; begin //MinimumDotNetInstalled := false; strRegValue := ReadRegEntry(strDotNet35RegistryPath, 'Install'); ShowMessage('Found 3.5 reg key: ' + strRegValue); if (strRegValue = #1) Then Begin strRegValue := ReadRegEntry(strDotNet30RegistryPath, 'InstallSuccess'); ShowMessage('Found 3.0 reg key: ' + strRegValue); if (strRegValue = #1) Then Begin strRegValue := ReadRegEntry(strDotNet20RegistryPath, 'Install'); ShowMessage('Found 3.5 reg key: ' + strRegValue); if (strRegValue = #1) Then Begin ShowMessage('Returning 1'); TI_MinimumDotNetInstalled := 1; End Else Begin ShowMessage('Returning 0'); TI_MinimumDotNetInstalled := 0; End End Else Begin ShowMessage('Returning 0'); TI_MinimumDotNetInstalled := 0; End End Else Begin ShowMessage('Returning 0'); TI_MinimumDotNetInstalled := 0; End end; exports TI_MinimumDotNetInstalled; begin end.