⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitdllfunctioncommon.pas

📁 酒店管理VB源码
💻 PAS
字号:
unit UnitDllFunctionCommon;

interface
uses
  windows,Compile_Hss,math,SysUtils,Complex_Hss;

  // 数据与字符串转换函数
  procedure cm_ExtendedToStr(const x : PExtended; const strBuffer : PChar; const nBufLen : integer); stdcall;
  procedure cm_StrToExtended(const strValue : PChar; const x : PExtended); stdcall;
  procedure cmcx_ComplexToStr(const x : PTComplex; const strBuffer : PChar; const nBufLen : integer); stdcall;
  function  cmcx_StrToComplex(const strValue : PChar; const x : PTComplex):longbool; stdcall;

  procedure VB_cmcx_ComplexToStr(const xComplexReal,xComplexImag : Double; const strBuffer : PChar; const nBufLen : integer); stdcall;
  function  VB_cmcx_StrToComplex(const strValue : PChar; const pComplexReal,pComplexImag : PDouble):longbool; stdcall;

  procedure VB_SinCos(const x: double; const pSin, pCos: PDouble); stdcall;
  function  VB_Ceil(const x:double):Double;stdcall;
  function  VB_ArcTan2(const y:double;const x:double):Double;stdcall;

implementation

procedure VB_SinCos(const x: double; const pSin, pCos: PDouble); stdcall;
asm
        FLD    x
        FSINCOS
        FSTP   QWord ptr [pCos]
        FSTP   QWord ptr [pSin]
        //FWAIT
end;

function  VB_ArcTan2(const y:double;const x:double):Double;stdcall;
asm
        FLD     Y
        FLD     X
        FPATAN
end;

function  VB_Ceil(const x:double):Double;stdcall;
var
	temp1,temp2: word; 
asm

      fld		x

      FNSTCW  temp1         // 保存协处理器控制字,用来恢复
      FNSTCW  temp2         // 保存协处理器控制字,用来修改
      FWAIT
      OR      temp2, 0B00H  // 使RC场向正无穷大取整    //必须保证 RC=00  然后改为 RC=10
      FLDCW   temp2         // 载入协处理器控制字,RC场已经修改
      FRNDINT
      FWAIT
      FLDCW   temp1         // 恢复协处理器控制字

end;


procedure cm_ExtendedToStr(const x : PExtended; const strBuffer : PChar; const nBufLen : integer); stdcall;
var
  str :string;
  i   : integer;
  L   : integer;
begin
  str:=floattostr(x^);
  L:=min(length(str),nBuflen);
  for i:=1 to L do
  begin
    PChar(DWORD(strBuffer)+DWORD(i-1))^:=str[i];
  end;
  if L<nBuflen then
    PChar(DWORD(strBuffer)+DWORD(L))^:=#0;

end;

procedure cm_StrToExtended(const strValue : PChar; const x : PExtended);stdcall;
var
  str : string;
begin
  str:=strValue;
  x^:=strtofloat(str);
end;

procedure cmcx_ComplexToStr(const x : PTComplex; const strBuffer : PChar; const nBufLen : integer);stdcall;
var
  str :string;
  i   : integer;
  L   : integer;
begin
  str:=TComplexToStr(x^);
  L:=min(length(str),nBuflen);
  for i:=1 to L do
  begin
    PChar(DWORD(strBuffer)+DWORD(i-1))^:=str[i];
  end;
  if L<nBuflen then
    PChar(DWORD(strBuffer)+DWORD(L))^:=#0;
end;

function cmcx_StrToComplex(const strValue : PChar; const x : PTComplex):longbool;stdcall;
var
  str : string;
begin
  str:=strValue;
  result:=StrToTComplex(str,x^);
end;

procedure VB_cmcx_ComplexToStr(const xComplexReal,xComplexImag : Double; const strBuffer : PChar; const nBufLen : integer); stdcall;
var
  cm  : TComplex;
begin
  cm.x:=xComplexReal;
  cm.y:=xComplexImag;
  cmcx_ComplexToStr(@cm,strBuffer,nBufLen);
end;

function  VB_cmcx_StrToComplex(const strValue : PChar; const pComplexReal,pComplexImag : PDouble):longbool; stdcall;
var
  cm  : TComplex;
begin
  result:=cmcx_StrToComplex(strValue,@cm);
  if result then
  begin
    pComplexReal^:=cm.x;
    pComplexImag^:=cm.y;
  end;
end;


end.

⌨️ 快捷键说明

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