Update of /cvsroot/gexperts/gexperts/unstable/Src/Utils
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv1588/Src/Utils
Modified Files:
GX_GenericUtils.pas GX_IdeUtils.pas GX_OtaUtils.pas
Log Message:
function RunningDelphi2007: Boolean;
function RunningDelphi2007OrGreater: Boolean;
function GetSpecialFolderPath(const FolderID: Integer): string;
function GetUserApplicationDataFolder: string;
D2007 support for: function GxOtaGetIDEProductIdentifier: string;
Index: GX_OtaUtils.pas
===================================================================
RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Utils/GX_OtaUtils.pas,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -r1.200 -r1.201
--- GX_OtaUtils.pas 23 Mar 2007 09:33:44 -0000 1.200
+++ GX_OtaUtils.pas 9 Apr 2007 05:53:31 -0000 1.201
@@ -2156,15 +2156,15 @@
Result := 'C++Builder'
else if RunningLinux then
Result := 'Kylix'
- else if RunningBDS2006OrGreater then
+ else if RunningBDS2006 then
Result := 'Borland Developer Studio'
else
- Result := 'Delphi';
+ Result := 'Delphi'; // Delphi 6/7/8/2005/2007. Check Cogswell.
end
else
begin
- Result := GxOtaGetIDEServices.GetProductIdentifier;
- Assert(Trim(Result) <> '', 'GetProductIdentifier returns nothing');
+ Result := GxOtaGetIDEServices.GetProductIdentifier; // D2007: 'CodeGear Delphi for Microsoft Windows'
+ Assert(NotEmpty(Result), 'GetProductIdentifier returns nothing');
end;
end;
Index: GX_IdeUtils.pas
===================================================================
RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Utils/GX_IdeUtils.pas,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- GX_IdeUtils.pas 22 Mar 2007 20:36:51 -0000 1.35
+++ GX_IdeUtils.pas 9 Apr 2007 05:53:31 -0000 1.36
@@ -68,6 +68,8 @@
function RunningDelphi7OrLess: Boolean;
function RunningDelphi7OrGreater: Boolean;
function RunningDelphi2005: Boolean;
+function RunningDelphi2007: Boolean;
+function RunningDelphi2007OrGreater: Boolean;
function RunningBDS2006OrGreater: Boolean;
function RunningBDS2006: Boolean;
function RunningCPPBuilder: Boolean;
@@ -416,6 +418,24 @@
{$ENDIF}
end;
+function RunningDelphi2007: Boolean;
+begin
+ {$IFDEF VER185}
+ Result := True;
+ {$ELSE}
+ Result := False;
+ {$ENDIF}
+end;
+
+function RunningDelphi2007OrGreater: Boolean;
+begin
+ {$IFDEF GX_VER185_up}
+ Result := True;
+ {$ELSE}
+ Result := False;
+ {$ENDIF}
+end;
+
function RunningBDS2006OrGreater: Boolean;
begin
{$IFDEF GX_VER180_up}
Index: GX_GenericUtils.pas
===================================================================
RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Utils/GX_GenericUtils.pas,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -d -r1.154 -r1.155
--- GX_GenericUtils.pas 22 Mar 2007 20:36:51 -0000 1.154
+++ GX_GenericUtils.pas 9 Apr 2007 05:53:31 -0000 1.155
@@ -403,6 +403,10 @@
// If RaiseException is True, an exception is raised on failure
function GXShellExecute(const FileName, Parameters: string; const RaiseException: Boolean): Boolean;
+// Get a Windows OS folder path. Pass in one of the ShlObj.CSIDL_ constants
+function GetSpecialFolderPath(const FolderID: Integer): string;
+function GetUserApplicationDataFolder: string;
+
// See if the current OS is Windows
function RunningWindows: Boolean;
// See if the current OS is some variant of UNIX
@@ -2686,6 +2690,42 @@
raise Exception.CreateFmt('%s (%s)', [SysErrorMessage(GetLastError), FileName]);
end;
+procedure FreeItemIDList(var IDList: PItemIDList);
+var
+ Malloc: IMalloc;
+begin
+ if Succeeded(SHGetMalloc(Malloc)) then
+ begin
+ if Malloc.DidAlloc(IdList) = 1 then
+ begin
+ Malloc.Free(IDList);
+ IDList := nil;
+ end;
+ end;
+end;
+
+function GetSpecialFolderPath(const FolderID: Integer): string;
+var
+ IDList: PItemIDList;
+begin
+ Result := '';
+ if SHGetSpecialFolderLocation(0, FolderID, IDList) = NOERROR then
+ try
+ SetLength(Result, MAX_PATH);
+ if SHGetPathFromIDList(IDList, PChar(Result)) then
+ SetLength(Result, StrLen(PChar(Result)));
+ finally
+ FreeItemIDList(IDList);
+ end;
+ if IsEmpty(Result) then
+ raise Exception.Create('Unable to get Windows path for system folder: ' + IntToStr(FOlderID));
+end;
+
+function GetUserApplicationDataFolder: string;
+begin
+ Result := GetSpecialFolderPath(CSIDL_APPDATA);
+end;
+
function RunningWindows: Boolean;
begin
{$IFDEF MSWINDOWS}
|