CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27

    Disable 'shift' key

    Hi all,

    Another tricky question - tell me, is it possible to disable the "shift" keys? Reason I ask is because I'm starting an MS-Access database in the background and I have to open a password protected database. All of which is working quite well, but if the user is savvy enough to know to hold down the shift key while and after my program pokes in the password - the database opens completely unprotected! (The user can view all forms/tables/fields, etc). I thought about disabling the whole keyboard but if my program happens to crash during execution, the user's only recourse is to hit the reset key. Not friendly!

    Essentially, while my program runs, I need to be able to stop the shift key being pressed and, after a certain point, re-enable it.

    Thanks,

    Mark

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Disable 'shift' key

    What program is getting the shift key state in order to make this happen?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27

    Re: Disable 'shift' key

    The program receiving the shift key state is MS-Access's "Password required" dialog box.

    My program looks up Active Directory to see who belongs to which security group, and (using MS-Access macros) opens the appropriate form.

    The problem is the database in which these forms/tables/data/macros are stored is password protected so that end users cannot see/edit what they shouldn't be able to see, if the program works the way it should.

    The problem is, my program uses "SendKeys" to send the password to the MS-Access "Password required" box. Now if the user's pretty savvy, he/she knows that holding down the shift key after the password has been entered disables all startup macros and the like!

    That's not good!

    Basically, I have two options:-

    Disable the shift key while my program's launching MS-Access or,

    Launching MS-Access vbMinimized unfocussed, then find the handle to the password required box, and do some messy API calls to sendkeys to the dialog box's handle.

    Any suggestions?

    Mark

    PS. While I can disable the entire keyboard, I don't want to do that because if my program happens to crash during execution, the user has no choice but to hit the reset button!

  4. #4
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27

    Re: Disable 'shift' key

    Hi,

    The program receiving the shift key state is MS-Access's "Password required" dialog box.

    My program looks up Active Directory to see who belongs to which security group, and (using MS-Access macros) opens the appropriate form.

    The problem is the database in which these forms/tables/data/macros are stored is password protected so that end users cannot see/edit what they shouldn't be able to see, if the program works the way it should.

    The problem is, my program uses "SendKeys" to send the password to the MS-Access "Password required" box. Now if the user's pretty savvy, he/she knows that holding down the shift key after the password has been entered disables all startup macros and the like!

    That's not good!

    Basically, I have two options:-

    Disable the shift key while my program's launching MS-Access or,

    Launching MS-Access vbMinimized unfocussed, then find the handle to the password required box, and do some messy API calls to sendkeys to the dialog box's handle.

    Any suggestions?

    Mark

    PS. While I can disable the entire keyboard, I don't want to do that because if my program happens to crash during execution, the user has no choice but to hit the reset button!

  5. #5
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Disable 'shift' key

    I'm not totally sure what you are doing and why, but if I was going to open a protected database, I'd do it within my program, thus maintain control. However, perhaps instead of sendkeys, you could use API. The SendMessageByString API seems appropriate for this.

    The part that confuses me though, is when you say:
    Now if the user's pretty savvy, he/she knows that holding down the shift key after the password has been entered disables all startup macros and the like!
    So, if the password is already entered, then what's the problem if they are being given access to the database? Are you saying you have something else which must be run afterward?

    Again, why can't you open the database within your own app?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

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

Featured