有谁知道用vb做一个小软件,怎样让它启动过后就不能再打开了?
含苞 的方法只适应于启动程序唯一的情况,如果将程序拷贝一份再运行就不能避免了,可以用查找窗口的方法,发现本程序的窗口就结束
比如我用的是mdiform
Hnd = FindWindows("ThunderRT6MDIForm", "MyTestFrom")
if hnd<>0 then end
注意:一定要用Main函数启动,在form加载之前判断
如果你想运行一次后就不能再运行了,也就是删除程序
以下是关于程序在运行的情况下删除本程序的代码:
不是VB,但可以参考!
int main(int argc,char*argv[])
{
HMODULE module=GetModuleHandle(0);
CHAR buf[MAX_PATH];
GetModuleFileName(module ,buf,sizeof buf);
CloseHandle(HANDLE(4));
_asm{
lea eax,buf
push 0
push 0
push eax
push ExitProcess
push module
push DeleteFile
push UnmapViewOfFile
ret
}
return 0;
}