global.pas

来自「Delphi + MapX程序框架(地图)源码程序」· PAS 代码 · 共 70 行

PAS
70
字号
unit Global;

interface

uses Forms, Windows, Messages, SysUtils ;

const
  CM_BASE = WM_USER;

type
  TRunDLL = function(App: TApplication; Scr: TScreen; Int: Integer): HRESULT;

function RunDLL(dllPath: string; Int: Integer): HRESULT;
function GetLongPathName(APath:String):String;

implementation

function RunDLL(dllPath: string; Int: Integer): HRESULT;
var
  DLLHandle: THandle;
  DLLProcedure: TRunDLL;
begin
  DLLHandle := LoadLibrary(pChar(dllPath));
  if DLLHandle <> 0 then
  begin
    @DLLProcedure := GetProcAddress(DLLHandle, 'DLLProcedure');
    if Assigned(DLLProcedure) then
    begin
      Result:= DLLProcedure(Application, Screen, Int);
    end;
  end;
end;

function GetLongPathName(APath: String):String;
var
  APos : Integer;
  AHandle : THandle;
  Data : TWin32FindData;
  IsBackSlash : Boolean;
begin
  APath:= ExpandFileName(APath);
  APos:= Pos('\',APath);
  Result:= Copy(APath,1,APos);
  Delete(APath,1,APos);
  repeat
    APos:= Pos('\',APath);
    IsBackSlash:= APos > 0;
    if Not IsBackSlash then
      APos:= Length(APath)+1;
    AHandle:= FindFirstFile(PChar(Result+Copy(APath,1,APos-1)),Data);
    if AHandle <> INVALID_HANDLE_VALUE then
    begin
      try
        Result:= Result+Data.cFileName;
        if IsBackSlash then Result:=Result+'\';
      finally
        Windows.FindClose(AHandle);
      end;
    end
    else begin
      Result:=Result+APath;
      Exit;
    end;
    Delete(APath,1,APos);
  until Length(APath) = 0;
end;


end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?