选择显示字体大小

限制应用程序只运行一次

32位操作系统中,可以用两种方法实现:

1.首先在global external functions声明外部函数如下:

function long findwindowa( ulong winhandle, string wintitle ) library ″user32″

然后在application的 open 事件中加入如下代码:

ulong l_handle, lu_class

string ls_name

ls_name = ″我的系统″ // 此处ls_name为系统主窗口的标题title

l_handle = findwindowa(lu_class, ls_name)

if l_handle > 0 then

messagebox(″提示信息″, ″应用程序″ + this.appname + ″已经运行,不能多次启动!″)

halt close

else

open(w_main) // 此处为系统主窗口

end if

这种方法是powerbuilder联机帮助中的一个例子,是以系统主窗口的标题title作为判别依据,若有其它与此title同名应用程序在运行,再想启动此程序也会报应用程序已经运行。你可以将title设为“计算器”,然后启动windows附件中计算器程序,再运行你的pb应用程序试试。

2.声明外部函数:

function ulong createmutexa (ulong lpmutexattributes, int binitialowner, ref string lpname) library ″kernel32.dll″

function ulong getlasterror () library ″kernel32.dll″

然后在application的 open 事件中加入如下代码:

ulong ll_mutex, ll_err

string ls_mutex_name

if handle (getapplication (), false) <> 0 then

ls_mutex_name = this.appname + char (0)

ll_mutex = createmutexa (0, 0, ls_mutex_name)

ll_err = getlasterror ()

if ll_err = 183 then

// 程序已经运行

messagebox (″提示信息″, ″程序已经运行了!″)

halt close

else

// 程序未运行

open(w_main)

end if

else //开发模式

open(w_main)

end if

这种方法必须在应用程序编译成可执行文件.exe后才有效.


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons