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

userxk 2003-09-29 04:11:57
如题。
...全文
46 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
);
计算器不知道
楼主辛苦开发的源码,0分放送。亲们只要评价五分就是对我的努力付出的最大回报! 此版本比v1.7的多增加了几个函数和方法,同时也修正了一些bug。 vb封装的一个控制窗口操作的类,使用非常简单!时刻更新。 clsWindow是VB6环境下使用的一个操作外部程序窗口的类,比如得到窗口句柄,得到窗口里某个文本框的内容。非常方便,使用它可以让您脱身于一堆api函数,功能强大使用简单! 这个类楼主很早就开始封装了,原本打算做成类似DOM对象那样,通过一堆getElmentByXXX等方法实现对桌面程序下各个窗口以及里面各个控件对象的自由访问,但是具体要做的工作太多,目前只实现了一部分,期待大家一起加入更新维护。 目前该类封装了绝大部分对windows窗口的常用操作,例如:获取窗口句柄,设置窗口为活动窗口,设置窗口内文本框内容,点击窗口内的某些按钮等。 这个类现在还在一直不断地扩充,功能已经很强大很广泛,使用它可以轻而易举地设置窗口标题栏文字,移动窗体等等。以前要实现这些操作常常需要一大堆api函数,现在只需要一点点代码就可以了,完全让您脱身于api函数的海洋。当然需要您需要研究每个方法实现原理的话可以看一看源代码。 使用范例: 1)关闭腾讯新闻窗口“腾讯网迷你版”。 Dim window As New clsWindow If window.GetWindowHwndByTitle("腾讯网迷你版") > 0 Then window.CloseWindow '关闭窗口 End If 以上是不是很简洁呢? 2)获取某个打开的记事本里面的内容。假设记事本标题为“测试.txt - 记事本”,通过SPY等工具查看得知记事本的文本框类为:Edit,那么我们编写程序如下: Dim window As New clsWindow If window.GetWindowHwndByTitle("测试.txt - 记事本") > 0 Then MsgBox window.GetElementTextByClassName("Edit") End If 这个看起来也很简单,方法自由还可以使用正则匹配,可以写成下面这样: Dim window As New clsWindow If window.GetWindowHwndByTitleRegExp("测试\.txt.*?") > 0 Then MsgBox window.GetElementTextByClassName("Edi", , True)'第三个参数表示是否使用正则,默认为false End If 更多演示案例: 演示程序一(关闭包含“扫雷、蜘蛛纸牌”等系统自带游戏的窗口): http://files.cnblogs.com/sysdzw/clsWindow1.7_demo1.rar 演示程序二(调用系统计算器,点击里面的按钮进行计算): http://files.cnblogs.com/sysdzw/clsWindow1.7_demo2.rar 演示程序三(激活移动外部程序窗口): http://files.cnblogs.com/sysdzw/clsWindow1.7_demo3.rar 演示程序四(调用系统计算器,花样移动出现,效果很好): http://files.cnblogs.com/sysdzw/clsWindow1.7_demo4.rar clsWindow类最新版下载请关注博客: http://blog.csdn.net/sysdzw/article/details/9083313 '=================================================================================== '描 述:一个操作windows窗口的类,可对窗口进行很多常用的操作(类为clsWindow) '使用范例:Dim window As New clsWindow ' window.GetWindowHwndByTitle "计算器" ' window.closeWindow '编 程:sysdzw 原创开发,如果有需要对模块扩充或更新的话请邮箱发我一份,共同维护 '发布日期:2013/06/01 '博 客:http://hi.baidu.com/sysdzw ' http://blog.csdn.net/sysdzw 'Email :sysdzw@163.com 'QQ :171977759 '版 本:V1.0 初版 2012/12/03 ' V1.1 修正了几个正则相关的函数,调整了部分类结构 2013/05/28 ' V1.2 增加属性Caption,可以获取或设置当前标题栏 2013/05/29 ' V1.3 增加了方法Focus,可以激活当前窗口 2013/06/01 ' 增加了方法Left,Top,Width,Height,Move,处理窗口位置等 ' V1.4 增加了窗口位置调整的几个函数 2013/06/04 ' 增加了得到应用程序路径的函数AppName ' 增加了得到应用程序启动参数的函数AppCommandLine ' V1.5 增加了窗口最大最小化,隐藏显示正常的几个函数 2013/06/06 ' 增加了获取控件相关函数是否使用正则的参数UseRegExp默认F ' V1.6 将Left,Top函数改为属性,可获得可设置 2013/06/10 ' V1.7 增加了CloseApp函数,可以结束进程 2013/06/13 ' 修正了部分跟正则匹配相关的函数 ' 增加函数:GetElementTextByText ' 增加函数:GetElementHwndByText ' V1.8 增加GetWindowHwndByClassName函数 2013/06/26 ' 增加GetWindowHwndByClassNameEx函数 ' 增加GetWindowHwndByAppName函数 ' 增加私有变量hWnd_ ' 增加属性hWnd,可设置,单设置时候会检查,非法则设置为0 ' 更新GetWindowHwndByTitleEx函数,使之可以选择性支持正则 ' 删除GetWindowHwndByTitleRegExp函数,合并到上面函数 ' 增加SetFocus函数,调用Focus实现,为了是兼容VB习惯 ' 扩了ProcessID、AppPath、AppName、AppCommandLine三个函数,可带参数 ' 网友wwb(wwbing@gmail.com)提供了一些函数和方法属性: ' CheckWindow, Load, WindowState, Visible, hDC, ZOrder ' AlphaBlend, Enabled, Refresh, TransparentColor ' 部分采纳网友意见,将句柄变量改为hWnd_,但是hWnd作为公共属性 '===================================================================================
clsWindow是VB6环境下使用的一个操作外部程序窗口的类,比如得到窗口句柄,得到窗口里某个文本框的内容。非常方便,使用它可以让您脱身于一堆api函数,功能强大使用简单! 这个类楼主很早就开始封装了,原本打算做成类似DOM对象那样,通过一堆getElmentByXXX等方法实现对桌面程序下各个窗口以及里面各个控件对象的自由访问,但是具体要做的工作太多,目前只实现了一部分,期待大家一起加入更新维护。 目前该类封装了绝大部分对windows窗口的常用操作,例如:获取窗口句柄,设置窗口为活动窗口,设置窗口内文本框内容,点击窗口内的某些按钮等。 这个类现在还在一直不断地扩充,功能已经很强大很广泛,使用它可以轻而易举地设置窗口标题栏文字,移动窗体等等。以前要实现这些操作常常需要一大堆api函数,现在只需要一点点代码就可以了,完全让您脱身于api函数的海洋。当然需要您需要研究每个方法实现原理的话可以看一看源代码。 使用范例: 1)关闭腾讯新闻窗口“腾讯网迷你版”。 Dim window As New clsWindow If window.GetWindowHwndByTitle("腾讯网迷你版") > 0 Then window.CloseWindow '关闭窗口 End If 以上是不是很简洁呢? 2)获取某个打开的记事本里面的内容。假设记事本标题为“测试.txt - 记事本”,通过SPY等工具查看得知记事本的文本框类为:Edit,那么我们编写程序如下: Dim window As New clsWindow If window.GetWindowHwndByTitle("测试.txt - 记事本") > 0 Then MsgBox window.GetElementTextByClassName("Edit") End If 这个看起来也很简单,方法自由还可以使用正则匹配,可以写成下面这样: Dim window As New clsWindow If window.GetWindowHwndByTitleRegExp("测试\.txt.*?") > 0 Then MsgBox window.GetElementTextByClassName("Edi", , True)'第三个参数表示是否使用正则,默认为false End If 更多演示案例: 演示程序一(关闭包含“扫雷、蜘蛛纸牌”等系统自带游戏的窗口): http://files.cnblogs.com/sysdzw/clsWindow1.7_demo1.rar 演示程序二(调用系统计算器,点击里面的按钮进行计算): http://files.cnblogs.com/sysdzw/clsWindow1.7_demo2.rar 演示程序三(激活移动外部程序窗口): http://files.cnblogs.com/sysdzw/clsWindow1.7_demo3.rar 演示程序四(调用系统计算器,花样移动出现,效果很好): http://files.cnblogs.com/sysdzw/clsWindow1.7_demo4.rar 类成员以及各个使用方法如下: clsWindow类下载地址: http://download.csdn.net/user/sysdzw clsWindow类最新版下载请关注博客: http://blog.csdn.net/sysdzw/article/details/9083313 '=================================================================================== '描 述:一个操作windows窗口的类,可对窗口进行很多常用的操作(类为clsWindow) '使用范例:Dim window As New clsWindow ' window.GetWindowHwndByTitle "计算器" ' window.closeWindow '编 程:sysdzw 原创开发,如果有需要对模块扩充或更新的话请邮箱发我一份,共同维护 '发布日期:2013/06/01 '博 客:http://hi.baidu.com/sysdzw ' http://blog.csdn.net/sysdzw 'Email :sysdzw@163.com 'QQ :171977759 '版 本:V1.0 初版 2012/12/03 ' V1.1 修正了几个正则相关的函数,调整了部分类结构 2013/05/28 ' V1.2 增加属性Caption,可以获取或设置当前标题栏 2013/05/29 ' V1.3 增加了方法Focus,可以激活当前窗口 2013/06/01 ' 增加了方法Left,Top,Width,Height,Move,处理窗口位置等 ' V1.4 增加了窗口位置调整的几个函数 2013/06/04 ' 增加了得到应用程序路径的函数AppName ' 增加了得到应用程序启动参数的函数AppCommandLine ' V1.5 增加了窗口最大最小化,隐藏显示正常的几个函数 2013/06/06 ' 增加了获取控件相关函数是否使用正则的参数UseRegExp默认F ' V1.6 将Left,Top函数改为属性,可获得可设置 2013/06/10 ' V1.7 增加了CloseApp函数,可以结束进程 2013/06/13 ' 修正了部分跟正则匹配相关的函数 ' 增加函数:GetElementTextByText ' 增加函数:GetElementHwndByText '===================================================================================

5,388

社区成员

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

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