一简单问题,怎样获取计算器名?

userxk 2003-09-29 04:11:57
如题。
...全文
44 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wz蝈蝈 2003-09-29
  • 打赏
  • 举报
回复
同意wangyj2003的方法。我迟到一步了。哈哈
wangyj2003 2003-09-29
  • 打赏
  • 举报
回复
var
CNameBuffer : PChar;
fl_loaded : Boolean;
CLen : ^DWord;
begin
GetMem(CNameBuffer,255);
New(CLen);
CLen^:= 255;
fl_loaded := GetComputerName(CNameBuffer,CLen^);
if fl_loaded then
ComputerName := StrPas(CNameBuffer)
else
ComputerName := 'Unkown';
FreeMem(CNameBuffer,255);
Dispose(CLen);
end;
userxk 2003-09-29
  • 打赏
  • 举报
回复
能不能给段实例代码?
zhoutian618 2003-09-29
  • 打赏
  • 举报
回复
他们回答的本来就取计算机名。
userxk 2003-09-29
  • 打赏
  • 举报
回复
不好意思,写错了。是计算机名。
空中居士 2003-09-29
  • 打赏
  • 举报
回复
计算器的程序名是 calc.exe
你可以通过查找系统目录如winnt\system32文件找到该文件。
调用方法:
ShellExecute(handle, nil, pchar('winnt\system32\calc.exe'), '','', SW_SHOWNORMAL);
Delphi_Li 2003-09-29
  • 打赏
  • 举报
回复
GetComputerName

The GetComputerName function retrieves the NetBIOS name of the local computer. This name is established at system startup, when the system reads it from the registry.

If the local computer is a node in a cluster, GetComputerName returns the name of the cluster virtual server.

GetComputerName retrieves only the NetBIOS name of the local computer. To retrieve the DNS host name, DNS domain name, or the fully qualified DNS name, call the GetComputerNameEx function. Additional information is provided by the IADsADSystemInfo interface.


BOOL GetComputerName(
LPTSTR lpBuffer,
LPDWORD lpnSize
);

Parameters
lpBuffer
[out] Pointer to a buffer that receives a null-terminated string containing the computer name or the cluster virtual server name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1 characters.
lpnSize
[in, out] On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs copied to the destination buffer, not including the terminating null character.
If the buffer is too small, the function fails and GetLastError returns ERROR_MORE_DATA. The lpnSize parameter specifies the size of the buffer required, not including the terminating null character.


Windows Me/98/95: GetComputerName fails if the input size is less than MAX_COMPUTERNAME_LENGTH + 1.


Return Values
If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Delphi_Li 2003-09-29
  • 打赏
  • 举报
回复
GetComputerName

The GetComputerName function retrieves the NetBIOS name of the local computer. This name is established at system startup, when the system reads it from the registry.

If the local computer is a node in a cluster, GetComputerName returns the name of the cluster virtual server.

GetComputerName retrieves only the NetBIOS name of the local computer. To retrieve the DNS host name, DNS domain name, or the fully qualified DNS name, call the GetComputerNameEx function. Additional information is provided by the IADsADSystemInfo interface.


BOOL GetComputerName(
LPTSTR lpBuffer,
LPDWORD lpnSize
);

Parameters
lpBuffer
[out] Pointer to a buffer that receives a null-terminated string containing the computer name or the cluster virtual server name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1 characters.
lpnSize
[in, out] On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs copied to the destination buffer, not including the terminating null character.
If the buffer is too small, the function fails and GetLastError returns ERROR_MORE_DATA. The lpnSize parameter specifies the size of the buffer required, not including the terminating null character.


Windows Me/98/95: GetComputerName fails if the input size is less than MAX_COMPUTERNAME_LENGTH + 1.


Return Values
If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

tw_cshn 2003-09-29
  • 打赏
  • 举报
回复
计算机还是计算器?
计算机是BOOL GetComputerName(

LPTSTR lpBuffer, // address of name buffer
LPDWORD nSize // address of size of name buffer
);
计算器不知道

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧