|
-
Feb 18th, 2003, 06:24 PM
#1
Thread Starter
Addicted Member
Password protection for a single outside application
Is it possible to prompt for a password when running certain apps? Notepad, or WinMine for instance.... doesn't really matter what program. Any program. Is it possible? How should I go about it?
I could watch foreground window captions until the condition is met, but I don't want to waste resources.
I could put my program in place of any shortcuts that would prompt for the password and run the app if necessary, but this won't protect the actual exe.
Anyone have better ideas about this?
-
Feb 19th, 2003, 02:40 AM
#2
Hyperactive Member
There are few ways you can do that, but the most effective one would be: create a program with a timer, and monitor for FindWindow (programclass, programcaption) <> 0. When the external program is loaded and FindWindow returns the handle number, you can hide the external program with SendMessage API (don't remember the constant) and prompt your password dialog. If user enters password correctly, you unhide the external program using probably the same SendMesage API, if incorrectly, you terminate it with SendMessage API with SW_CLOSE.
Timer interval could be set to 1000 (meaning every second). Timer doesn't really eat up neither your resources nor CPU usage.
Last edited by Dmitri K; Feb 19th, 2003 at 02:44 AM.
-
Feb 19th, 2003, 03:09 AM
#3
Frenzied Member
Or U could use what is called an "EXE_Wrap" application. It calls for a few resgistry changes though.
VB Code:
'Logging use of executables in Windows
'This handy little tip can be used to log the use
'of .exe, .lnk, .pif, .bat, and .com files on your computer. All it
'needs is a little registry tinkering. Place this code in a module,
'and set the project startup object to 'Sub Main'
Sub Main()
If Command$ <> "" Then
Open "c:\apps\exelog.txt" For Append As #1
Print #1, Command$ & " " & CStr(Now)
Close #1
Call Shell(Command$, vbNormalFocus)
End If
End
End Sub
'Registry Changes
'The registry changes are:
'HKEY_CLASSES_ROOT\exefile\shell\open\command to: "C:\exewrap.exe" "%1" %*
'HKEY_CLASSES_ROOT\lnkfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
'HKEY_CLASSES_ROOT\piffile\shell\open\command to: "C:\exewrap.exe" "%1" %*
'HKEY_CLASSES_ROOT\batfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
'HKEY_CLASSES_ROOT\comfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
'What happens it that instead of running the program directly,
'Windows calls our program, which logs filename and time, and
'then calls the program.
Now instead of
VB Code:
Open "c:\apps\exelog.txt" For Append As #1
Print #1, Command$ & " " & CStr(Now)
Close #1
Call Shell(Command$, vbNormalFocus)
U could use an "IF-THEN-ELSE" construct to display popup for a pasword and only if valid, call the "Shell" command
HTH
Regards
KayJay
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Feb 19th, 2003, 05:12 PM
#4
Thread Starter
Addicted Member
Dmitri K -That's kind of what I had in mind to try, but I don't like to run timers that way. I don't want to risk wasting resources, but I have really no idea if that does. It just seems like it would. If you know about timer efficiency, set me straight.
KayJay -Interesting solution. I haven't heard of this before. I need to know a few things about it. What operating systems does that work on? Can it me implemented to restrict a single exe? Sounds like a good idea..
-
Feb 20th, 2003, 12:41 AM
#5
Frenzied Member
Originally posted by mr_metal_hed
Dmitri K -That's kind of what I had in mind to try, but I don't like to run timers that way. I don't want to risk wasting resources, but I have really no idea if that does. It just seems like it would. If you know about timer efficiency, set me straight.
KayJay -Interesting solution. I haven't heard of this before. I need to know a few things about it. What operating systems does that work on? Can it me implemented to restrict a single exe? Sounds like a good idea..
It should work on all WIN32 OSes. To restrict access to just one exe, U could add code in your "EXEWrap.EXE" application to check for what is the value of the "Command$" variable. If it is "Notepad", pop a password prompt, else just continue with Shelling the app.
Regards
KayJay
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|