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