vb 使程序不能双击运行
发布网友
发布时间:2024-04-07 17:45
我来回答
共5个回答
热心网友
时间:2024-04-15 12:45
添加命令行参数。
可以在模块里的Sub Main()里,也可以在Form_Load()里。都差不多。就拿Sub Main()举例了。反正都是起到时执行的代码块:
Sub Main()
If command <> "-芝麻开门" Then End
'意思是,如果指令不是“芝麻开门”那就结束,也就是说双击是空的指令所以自然就打不开了。
End Sub
'------------------------------------------调用的代码:
Shell "C:\这个程序.exe -芝麻开门"
'这样打开那个程序就可以了。
热心网友
时间:2024-04-15 12:45
Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32MoleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 260
End Type
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags&, ByVal th32PID&) As Long
Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Function GetParentPid(ByVal AppPid As Long) As PROCESSENTRY32
Dim Process As PROCESSENTRY32
Dim hSnapShot As Long
Dim pid As Long
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&) '建立进程快照
If hSnapShot Then
Process.dwSize = 1060
If (Process32First(hSnapShot, Process)) Then '遍历第一个进程,获得PROCESSENTRY32结构
Do
If AppPid = Process.th32ProcessID Then
GetParentPid = Process
Exit Do
End If
Loop Until (Process32Next(hSnapShot, Process) < 1) '遍历所有进程直到返回值为False
End If
Call CloseHandle(hSnapShot)
End If
End Function
Private Sub Form_Load()
If UCase$(Replace(GetParentPid(GetCurrentProcessId).szExeFile, vbNullChar,""))="EXPLORER" Then
End
End If
End Sub追问不行啊,仍能双击运行
追答把这一句修改一下:
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&) '建立进程快照
改成
hSnapShot = CreateToolhelp32Snapshot(2, 0&) '建立进程快照
再试试
热心网友
时间:2024-04-15 12:46
是占用吧
在注册表里占用就行了
不过占用了 程序关掉就又恢复了
热心网友
时间:2024-04-15 12:46
详细一点,是双击打开吗?那是做不到的,
热心网友
时间:2024-04-15 12:47
有个鼠标双击事件,把它禁用就可以了追问如何禁用???
追答你把这个程序隐藏起来吧,把这个运行程序打包起来,然后用调用