打印本文 打印本文 关闭窗口 关闭窗口
Delphi之三十六计之系统篇
作者:武汉SEO闵涛  文章来源:敏韬网  点击数620  更新时间:2009/4/23 18:24:38  文章录入:mintao  责任编辑:mintao
  1.NT 还是 Windows 98?取得当前操作平台

 Function GetOSInfo : String;

 begin

  Result := "";
  case Win32Platform of
  VER_PLATFORM_WIN32_WINDOWS: Result := "Windows 95/98";
  VER_PLATFORM_WIN32_NT: Result := "Windows NT";

 else

  Result := "Windows32";
 end;
 end;

  2.获取当前Windows用户的登录名

function GetCurrentUserName : string;

 const
  cnMaxUserNameLen = 254;
 var
  sUserName : string;
  dwUserNameLen : Dword;
 begin
  dwUserNameLen := cnMaxUserNameLen-1;
  SetLength( sUserName, cnMaxUserNameLen );
  GetUserName(Pchar( sUserName ), dwUserNameLen );
  SetLength( sUserName, dwUserNameLen );
  Result := sUserName;
 end;

  3. Windows控制面板的访问

//在窗体的Private节中作ExecuteFile函数声明,并在实现部分书写如下代码:

 function TForm1.ExecuteFile(const Params: String): Thandle;
 var
  zFileName, zParams, zDir: array[0..79] of Char;
 begin
  Result := ShellExecute(Application.MainForm.Handle,
       nil,StrPCopy(zFileName, "c:\windows\rundll32.exe"),
       StrPCopy(zParams, Params),
       StrPCopy(zDir, "c:\windows\"),
       SW_SHOW);
 end;

打印本文 打印本文 关闭窗口 关闭窗口