各位兄弟们,我想调用dll文件来显示系统的信息,比如内存量,cpu型号,操作系统什么的,我的dll文件编译成功了,没有提示错误,但是我调用的时候却没有任何内容,请问是怎么回事,我把代码贴出来:
unit U_OS;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,ExtCtrls;
type
  TF_OS = class(TForm)
    B_Close: TButton;
    ListBox1: TListBox;
    procedure ShowOSInfo;
    procedure B_CloseClick(Sender: TObject);
end;
function ShowOS(AHandle:THandle):String;StdCall;
var
  F_OS: TF_OS;
implementation
{$R *.dfm}
procedure TF_OS.ShowOSInfo;
const
  SOSWin32s='Window 3.1x running Win32s';
  SOSWin95='Windows 95';
  SOSWinNT='Windows NT';
var
  MS:TMemoryStatus;
  VI:TOSVersionInfo;
  SI:TsystemInfo;
begin
  MS.dwLength:=Sizeof(MS);
  GlobalMemoryStatus(MS);
  VI.dwOSVersionInfoSize:=Sizeof(VI);
  GetVersionEx(VI);
  GetSystemInfo(SI);
  with ListBox1.Items do
  begin
    clear;
    Add(Format('内存占用率: %d%%',[MS.dwMemoryLoad]));
    Add(Format('物理内存大小: $%.8x bytes',[MS.dwTotalPhys]));
    Add(Format('空闲物理内存: $%.8x bytes',[MS.dwAvailPhys]));
    Add(Format('页面文件大小: $%.8x bytes',[MS.dwTotalPageFile]));
    Add(Format('空闲页面文件大小: $%.8x bytes',[MS.dwAvailPageFile]));
    Add(Format('虚拟内存大小: $%.8x bytes',[MS.dwTotalVirtual]));
    Add(Format('空闲虚拟内存大小: $%.8x bytes',[MS.dwAvailVirtual]));
    Add(Format('操作系统版本:  %d.%d',[VI.dwMajorVersion,VI.dwMinorVersion]));
    Add(Format('序列号:  %d',[VI.dwBuildNumber]));
    case VI.dwPlatformID of
      VER_PLATFORM_WIN32s:Add(Format('操作平台:  %s',[SOSWin32s]));
      VER_PLATFORM_WIN32_WINDOWS:Add(Format('操作平台:  %s',[SOSWin95]));
      VER_PLATFORM_WIN32_NT:Add(Format('操作平台:  %s',[SOSWinNT]));
    end;
    case SI.wProcessorLevel of
      3:ListBox1.Items.Add(Format('处理器类型:  %s',['80386']));
      4:ListBox1.Items.Add(Format('处理器类型:  %s',['80486']));
      5:ListBox1.Items.Add(Format('处理器类型:  %s',['Pentium']));
    else
      ListBox1.Items.Add(Format('处理器类型:  %s',[InttoStr(SI.wProcessorLevel)]));
    end;
  end;
end;
function ShowOS(AHandle:THandle):String;StdCall;
begin
  Application.Handle:=AHandle;
  F_OS:=TF_OS.Create(Application);
  F_OS.Show;
end;
procedure TF_OS.B_CloseClick(Sender: TObject);
begin
  Close;
end;
end.library P_OSInfo;
uses
  ShareMem,
  SysUtils,
  Classes,
  U_OS in 'U_OS.pas' {F_OS};
{$R *.res}
exports
  ShowOS name 'ShowOS';
begin
end.调用的过程
procedure TF_main.PM_system_infoClick(Sender: TObject);
begin
  ShowOS(Application.Handle);
end;

解决方案 »

  1.   

    是不是在F_OS窗体初始化时要调用ShowOSInfo的啊!
      

  2.   

    F_OS.Create()的事件里调用ShowOSInfo
      

  3.   

    我的本来意图是在dll文件中建立一个函数showos用来打开窗体,当调用dll文件的时候会传递一个handle变量,用来建立窗体,这样在应用程序中调用就能打开窗体了,但是所有的信息却显示不出来。