delphi 動態調用API


好處沒有這個API 也可以啟動程序只是調用會出錯.

function __IsNativeVhdBoot: Boolean;
type
  TIsNativeVhdBoot = function(
    NativeVhdBoot: pBOOL
  ): BOOL; stdcall;
var
  bNativeVhdBoot: pBOOL;
  NativeVhdBoot : TIsNativeVhdBoot;
begin
  Result := False;
  NativeVhdBoot := GetProcAddress(GetModuleHandle(kernel32), 'IsNativeVhdBoot');
  if (@NativeVhdBoot <> nil) then
  begin
    if not NativeVhdBoot(bNativeVhdBoot) then
      RaiseLastOSError;
    Result := bNativeVhdBoot^;
  end
  else
    RaiseLastOSError;
end;

  

固態調用 (沒有這個API啟動會失敗)

function IsNativeVhdBoot(NativeVhdBoot:PBOOL):BOOL; external Kernel32 name 'IsNativeVhdBoot';

function _IsNativeVhdBoot:Boolean;
var
  pB:PBOOL;
begin
  Result := False;
  if IsNativeVhdBoot(pB) then
    Result := pB^
  else RaiseLastOSError;
end;

  

 

關於Delphi XE 5 中編譯DevExpress VCL中的cxDateUtils單元

編譯cxLibrary如下函數出錯:

 

  1.  
    function GetEraYearOffset(const Name: string): Integer;
  2.  
    var
  3.  
    I: Integer;
  4.  
    begin
  5.  
    Result := 0;
  6.  
    for I := Low(EraNames) to High(EraNames) do
  7.  
    begin
  8.  
    if EraNames[I] = '' then
  9.  
    Break;
  10.  
    if AnsiStrPos(PChar(EraNames[I]), PChar(Name)) <> nil then
  11.  
    begin
  12.  
    Result := EraYearOffsets[I];
  13.  
    Exit;
  14.  
    end;
  15.  
    end;
  16.  
    end;

 

是因為SysUtils做了修改,對應修改如下:

 

  1.  
    function GetEraYearOffset(const Name: string): Integer;
  2.  
    var
  3.  
    I: Integer;
  4.  
    begin
  5.  
    Result := 0;
  6.  
    for I := Low(FormatSettings.EraInfo) to High(FormatSettings.EraInfo) do
  7.  
    begin
  8.  
    if FormatSettings.EraInfo[I].EraName = '' then
  9.  
    Break;
  10.  
    if AnsiStrPos(PChar(FormatSettings.EraInfo[I].EraName), PChar(Name)) <> nil
  11.  
    then
  12.  
    begin
  13.  
    Result := FormatSettings.EraInfo[I].EraOffset;
  14.  
    Exit;
  15.  
    end;
  16.  
    end;
  17.  
    end;

 

 

還有一處:

 

  1.  
        if AnsiPos('e', AFormat.ShortDateFormat) > 0 then 
  2.  
    AEraYearOffset := EraYearOffsets[ 1];

 

對應修改為:

 

  1.  
    if AnsiPos('e', AFormat.ShortDateFormat) > 0 then
  2.  
    AEraYearOffset := FormatSettings.EraInfo[ 1].EraOffset;

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM