Sfoglia il codice sorgente

* win/sysutils.pp: Use GetModuleHandle for dynamic loading of kernel32.dll instead of LoadLibrary, this is possible because kernel32 is statically linked by RTL and is therefore always loaded with application. Also makes FreeLibrary at finalization unnecessary.
- Removed checks for Windows version, they are redundant. GetProcAddress simply returns nil if the function is not present.

git-svn-id: trunk@16540 -

sergei 15 anni fa
parent
commit
c5162a7816
1 ha cambiato i file con 4 aggiunte e 12 eliminazioni
  1. 4 12
      rtl/win/sysutils.pp

+ 4 - 12
rtl/win/sysutils.pp

@@ -1061,7 +1061,6 @@ Procedure LoadVersionInfo;
 Var
 Var
    versioninfo : TOSVERSIONINFO;
    versioninfo : TOSVERSIONINFO;
 begin
 begin
-  kernel32dll:=0;
   GetDiskFreeSpaceEx:=nil;
   GetDiskFreeSpaceEx:=nil;
   versioninfo.dwOSVersionInfoSize:=sizeof(versioninfo);
   versioninfo.dwOSVersionInfoSize:=sizeof(versioninfo);
   GetVersionEx(versioninfo);
   GetVersionEx(versioninfo);
@@ -1071,14 +1070,9 @@ begin
   Win32BuildNumber:=versionInfo.dwBuildNumber;
   Win32BuildNumber:=versionInfo.dwBuildNumber;
   Move (versioninfo.szCSDVersion ,Win32CSDVersion[1],128);
   Move (versioninfo.szCSDVersion ,Win32CSDVersion[1],128);
   win32CSDVersion[0]:=chr(strlen(pchar(@versioninfo.szCSDVersion)));
   win32CSDVersion[0]:=chr(strlen(pchar(@versioninfo.szCSDVersion)));
-  if ((versioninfo.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS) and
-    (versioninfo.dwBuildNUmber>=1000)) or
-    (versioninfo.dwPlatformId=VER_PLATFORM_WIN32_NT) then
-    begin
-       kernel32dll:=LoadLibrary('kernel32');
-       if kernel32dll<>0 then
-         GetDiskFreeSpaceEx:=TGetDiskFreeSpaceEx(GetProcAddress(kernel32dll,'GetDiskFreeSpaceExA'));
-    end;
+  kernel32dll:=GetModuleHandle('kernel32');
+  if kernel32dll<>0 then
+    GetDiskFreeSpaceEx:=TGetDiskFreeSpaceEx(GetProcAddress(kernel32dll,'GetDiskFreeSpaceExA'));
 end;
 end;
 
 
 Const
 Const
@@ -1393,8 +1387,6 @@ Initialization
   OnBeep:=@SysBeep;
   OnBeep:=@SysBeep;
 Finalization
 Finalization
   DoneExceptions;
   DoneExceptions;
-  if kernel32dll<>0 then
-   FreeLibrary(kernel32dll);
- if CFGDLLHandle<>0 then
+  if CFGDLLHandle<>0 then
    FreeLibrary(CFGDllHandle);
    FreeLibrary(CFGDllHandle);
 end.
 end.