用户登陆 用户注册
您的位置:首页> 电脑专栏>内容正文
Powerbuilder 编程获取本地主机名
[正文]: 一.调用api        1.首先声明api函数          function boolean getcomputernamea(ref string computer_hostname,ref ulong hostname_buffer) library "kernel32.dll" alias for "getcomputernamea;ansi"       2.pb中的代码如下:          string gethostname         gethostname=space(512)         ulong hostnamebuffer=512         getcomputernamea(gethostname,hostnamebuffer)         messagebox("本地主机名获取信息","本地主机名是:"+gethostname+"",question!,ok!)


    二.在windows xp/2003操作系统中"\windows\system32\"下有一个"hostname.exe"文件,可以用它获取本地主机名.    代码如下:      1.新建一个批处理文件,暂命名为hostnameinput.bat,存在c:盘根录下,包含如下内容:       @echo off       c:\windows\system32\hostname.exe > c:\hostnamefile.txt       copy c:\hostnamefile.txt c:\temp.txt      2.pb中的代码如下:        do until fileexists("c:\temp.txt")=false             filedelete("c:\temp.txt")              yield()        loop         run("c:\hostnameinput.bat",minimized!)        do until fileexists("c:\temp.txt")=true             filedelete("c:\temp.txt")              yield()        loop         int readhostname         readhostname=fileopen("c:\hostnamefile.txt",streammode!,read!)         string gethostname         fileread(readhostname ,gethostname)        fileclose(readhostname)         messagebox("本地主机名获取信息","本地主机名是:"+gethostname+"",question!,ok!)        filedelete("c:\temp.txt")


网站首页 培训课程 维修指南
技术文章 家电专栏 供应信息
求购信息 培训资讯 展会信息
电脑专栏 教程下载 资料下载
常用软件 PLC教程 PLC资料
变频伺服 低压电器 维修资料
人机界面 自控仪表 工控机类
文章标题: 搜文章
中国工控资源网手机版 2012
电话:010-67577139 13811659603
培训咨询QQ:657167934 471895637 销售咨询QQ:623769457
联系邮箱:zggkzyw@163.com
 京ICP备11002135号
报时(2026-04-02 12:09:31) 流量统计