Results 1 to 5 of 5

Thread: Password protection for a single outside application

  1. #1

    Thread Starter
    Addicted Member mr_metal_hed's Avatar
    Join Date
    Aug 2002
    Location
    NC
    Posts
    149

    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?

  2. #2
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444
    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.

  3. #3
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Or U could use what is called an "EXE_Wrap" application. It calls for a few resgistry changes though.
    VB Code:
    1. 'Logging use of executables in Windows
    2. 'This handy little tip can be used to log the use
    3. 'of .exe, .lnk, .pif, .bat, and .com files on your computer. All it
    4. 'needs is a little registry tinkering. Place this code in a module,
    5. 'and set the project startup object to 'Sub Main'
    6.  
    7. Sub Main()
    8. If Command$ <> "" Then
    9. Open "c:\apps\exelog.txt" For Append As #1
    10. Print #1, Command$ & " " & CStr(Now)
    11. Close #1
    12. Call Shell(Command$, vbNormalFocus)
    13. End If
    14. End
    15. End Sub
    16.  
    17. 'Registry Changes
    18.  
    19. 'The registry changes are:
    20.  
    21. 'HKEY_CLASSES_ROOT\exefile\shell\open\command to: "C:\exewrap.exe" "%1" %*
    22. 'HKEY_CLASSES_ROOT\lnkfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
    23. 'HKEY_CLASSES_ROOT\piffile\shell\open\command to: "C:\exewrap.exe" "%1" %*
    24. 'HKEY_CLASSES_ROOT\batfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
    25. 'HKEY_CLASSES_ROOT\comfile\shell\open\command to: "C:\exewrap.exe" "%1" %*
    26.  
    27. 'What happens it that instead of running the program directly,
    28. 'Windows calls our program, which logs filename and time, and
    29. 'then calls the program.

    Now instead of
    VB Code:
    1. Open "c:\apps\exelog.txt" For Append As #1
    2. Print #1, Command$ & " " & CStr(Now)
    3. Close #1
    4. 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

  4. #4

    Thread Starter
    Addicted Member mr_metal_hed's Avatar
    Join Date
    Aug 2002
    Location
    NC
    Posts
    149
    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..

  5. #5
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    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
  •  



Click Here to Expand Forum to Full Width