用户登陆 用户注册
您的位置:首页> 电脑专栏>内容正文
Powerbuilder编程创建快捷方式
[正文]: 一.先声明两个api函数.          function boolean getusernamea(ref string nowusername, ref ulong usernamelength) library "advapi32.dll" alias for "getusernamea;ansi"       //getusernamea函数用于获取当前登录操作系统的用户名.        function ulong getshortpathnamea(string filepathsource, ref string nowfilepath, ulong filepathlen) library "kernel32.dll" alias for "getshortpathnamea;ansi"       //getshortpathnamea函数用于将windows中的长文件名转换为dos下的短文件名.       注:如果你使用的是powerbuilder10.0,则api函数后面的"alias for....;ansi"必不可少,否则容易出现乱码.    二.在应用程序窗体中新增一个命令按钮(commandbutton),在按钮的单击事件中(clicked)包含如下内容:    //先获取当前登录操作系统的用户名         string getusername     string ls_var     ulong  setusernamelen     boolean tt     setusernamelen = 255    getusername = space( 255 )     tt = getusernamea(getusername, setusernamelen)     //将当前windows桌面的长路径更改为dos下的短路径     string nowfilepath    string filepathsource    filepathsource="c:\documents and settings\"+getusername+"\桌面\"    nowfilepath=space(255)     getshortpathnamea(filepathsource,nowfilepath,255)     //利用批处理文件创建快捷方式     do until fileexists("c:\a.bat")=false        filedelete("c:\a.bat")       yield()    loop    do until fileexists("c:\a.txt")=false        filedelete("c:\a.txt")       yield()    loop    //临时创建一个文件,用于判断批处理文件是否执行完毕.    int tempfile_a       tempfile_a=fileopen("c:\t.txt",linemode!,write!,lockwrite!,append!)       fileclose(tempfile_a)      //创建指批处理文件    int tempfile_b       tempfile_b=fileopen("c:\a.bat",linemode!,write!,lockwrite!,append!)       filewrite(tempfile_b,"@echo off")       filewrite(tempfile_b,"echo [internetshortcut] >"+" "+nowfilepath+"晋城教育网.url")       filewrite(tempfile_b,"echo url=http://www.0356edu.com "+">>"+" "+nowfilepath+"晋城教育网.url")       filewrite(tempfile_b,"copy c:\t.txt c:\a.txt")       fileclose(tempfile_b)      //执行指批处理文件    run("c:\a.bat",minimized!)   do until fileexists("c:\a.txt")=true       yield()   loop   messagebox("提示信息","快捷方式创建完毕",question!,ok!) 


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