Click here to Skip to main content
15,920,503 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Locking and Unlocking LogFile Pin
James R. Twine20-Feb-08 7:12
James R. Twine20-Feb-08 7:12 
QuestionRe: Locking and Unlocking LogFile Pin
David Crow20-Feb-08 7:37
David Crow20-Feb-08 7:37 
QuestionHow to get a local printer status? Pin
Skywalker200820-Feb-08 5:16
Skywalker200820-Feb-08 5:16 
AnswerRe: How to get a local printer status? Pin
David Crow20-Feb-08 5:31
David Crow20-Feb-08 5:31 
GeneralRe: How to get a local printer status? Pin
Skywalker200821-Feb-08 6:09
Skywalker200821-Feb-08 6:09 
GeneralInstall which windows compoents before install Visual Studio 2003 Pin
akira3220-Feb-08 5:06
akira3220-Feb-08 5:06 
GeneralRe: Install which windows compoents before install Visual Studio 2003 Pin
Mark Salsbery20-Feb-08 5:41
Mark Salsbery20-Feb-08 5:41 
QuestionCannot get reference to Locked screen when the system is in RDP state Pin
Abdul_khaliq_20-Feb-08 4:42
Abdul_khaliq_20-Feb-08 4:42 
Read the senario first in order to understand the problem

I had compile service in order to logon to windows remotely. I am achieving this by opening a reference to winst0 desktop and getting the reference of the login windows and set the username and password.

There are 3 states in which the user name and password can be passed.

1. when the system is at logged out state i.e no user has logged on (my service is working in this state)

2. when the system is at locked out state by pressing ctrl+alt+delete and selecting lock option (my service is working in this state also)

3. when the target system is accessed via RDP, the target computer goes into locked state, this is where is am facing problem.

I cannot get the reference to the locked window.

Can any one please let me know what is the problem and how do i get the problem solved.

here is the code

HWINSTA hWinStaUser = OpenWindowStation("WinSta0", FALSE, MAXIMUM_ALLOWED);<br />
if(SetProcessWindowStation(hWinStaUser))<br />
{<br />
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());<br />
// Switch into the Winlogon desktop<br />
if (SelectDesktop("Winlogon"))<br />
{<br />
//myfile << "failed to select logon desktop\n";<br />
//return FALSE;<br />
//myfile << "generating ctrl-alt-del\n";<br />
HWND hwndCtrlAltDel = FindWindow("SAS window class", "SAS window");<br />
if (hwndCtrlAltDel == NULL) {<br />
myfile << "\"SAS window\" not found\n";<br />
hwndCtrlAltDel = HWND_BROADCAST;<br />
}else{<br />
SendMessage(hwndCtrlAltDel, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));<br />
}<br />
HWND w=NULL;<br />
<br />
if( NULL != (w=FindWindow(NULL,"Welcome to Windows")) || NULL != (w=FindWindow(NULL,"Computer Locked")) || hwndCtrlAltDel!=NULL )<br />
// SendMessage(w, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL,VK_DELETE));<br />
Sleep(1000);<br />
// username<br />
// Alt-U for username edit<br />
if(NULL != (w=FindWindow(NULL,"Log On to Windows")) || NULL != (w=FindWindow(NULL,"Unlock Computer")) ){<br />
keybd_event( VK_MENU, 0, 0, NULL );<br />
keybd_event( VkKeyScan('u'), 1, 0, NULL );<br />
keybd_event( VkKeyScan('u'), 1, KEYEVENTF_KEYUP, NULL );<br />
keybd_event( VK_MENU, 0, KEYEVENTF_KEYUP, NULL );<br />
Sleep( 50 ); // maybe not needed<br />
<br />
// Enter the Username<br />
char username[] = "Administrator";<br />
for( int c=0; c<strlen(username); c++="" )<br="" mode="hold" />{<br />
keybd_event( VkKeyScan(username[c]), 1, 0, NULL );<br />
keybd_event( VkKeyScan(username[c]), 1, KEYEVENTF_KEYUP, NULL );<br />
}<br />
// Alt-P for password edit<br />
keybd_event( VK_MENU, 0, 0, NULL );<br />
keybd_event( VkKeyScan('p'), 1, 0, NULL );<br />
keybd_event( VkKeyScan('p'), 1, KEYEVENTF_KEYUP, NULL );<br />
keybd_event( VK_MENU, 0, KEYEVENTF_KEYUP, NULL );<br />
Sleep( 50 ); // maybe not needed<br />
<br />
// Enter the password<br />
char password[] = "admin";<br />
for( int c=0; c<strlen(password); c++="" )<br="" mode="hold" />{<br />
keybd_event( VkKeyScan(password[c]), 1, 0, NULL );<br />
keybd_event( VkKeyScan(password[c]), 1, KEYEVENTF_KEYUP, NULL );<br />
}<br />
// Send the enter key and do the default (logon)<br />
<br />
HWND hwndDomain;<br />
int dwIndex;<br />
if(NULL!= (hwndDomain = GetDlgItem(w, 1504)) || NULL!= (hwndDomain = GetDlgItem(w, 1956))){<br />
dwIndex = (DWORD) SendMessage(hwndDomain, CB_FINDSTRINGEXACT, 0, (LPARAM) "DOMAIN1");<br />
}<br />
if (dwIndex != CB_ERR)<br />
{<br />
SendMessage(hwndDomain, CB_SETCURSEL, (WPARAM) dwIndex, 0);<br />
}<br />
keybd_event( VK_RETURN, 0, 0, NULL );<br />
keybd_event( VK_RETURN, KEYEVENTF_KEYUP, 0, NULL );<br />
}<br />
// Switch back to our original desktop<br />
if (old_desktop != NULL)<br />
SelectHDESK(old_desktop);<br />
}<br />
if (hWinStaUser)<br />
CloseWindowStation(hWinStaUser);<br />
}

GeneralRe: Cannot get reference to Locked screen when the system is in RDP state Pin
James R. Twine20-Feb-08 7:21
James R. Twine20-Feb-08 7:21 
QuestionRe: Cannot get reference to Locked screen when the system is in RDP state Pin
Abdul_khaliq_20-Feb-08 19:49
Abdul_khaliq_20-Feb-08 19:49 
QuestionCompiles with VC6. Is this still available? Pin
Ylno20-Feb-08 4:14
Ylno20-Feb-08 4:14 
AnswerRe: Compiles with VC6. Is this still available? Pin
CPallini20-Feb-08 4:34
mveCPallini20-Feb-08 4:34 
GeneralRe: Compiles with VC6. Is this still available? Pin
Ylno20-Feb-08 5:14
Ylno20-Feb-08 5:14 
QuestionRe: Compiles with VC6. Is this still available? Pin
CPallini20-Feb-08 7:32
mveCPallini20-Feb-08 7:32 
GeneralRe: Compiles with VC6. Is this still available? Pin
Ylno20-Feb-08 8:54
Ylno20-Feb-08 8:54 
GeneralRe: Compiles with VC6. Is this still available? Pin
CPallini20-Feb-08 9:49
mveCPallini20-Feb-08 9:49 
GeneralRe: Compiles with VC6. Is this still available? Pin
Ylno20-Feb-08 10:51
Ylno20-Feb-08 10:51 
AnswerRe: Compiles with VC6. Is this still available? Pin
David Crow20-Feb-08 5:35
David Crow20-Feb-08 5:35 
GeneralRe: Compiles with VC6. Is this still available? Pin
Ylno20-Feb-08 5:49
Ylno20-Feb-08 5:49 
AnswerRe: Compiles with VC6. Is this still available? Pin
Chris Losinger20-Feb-08 9:04
professionalChris Losinger20-Feb-08 9:04 
Question[Message Deleted] Pin
1dayprogrammer20-Feb-08 4:08
1dayprogrammer20-Feb-08 4:08 
QuestionRe: code error..., in writing code to a file?? Pin
David Crow20-Feb-08 5:38
David Crow20-Feb-08 5:38 
GeneralRe: code error..., in writing code to a file?? Pin
1dayprogrammer20-Feb-08 7:14
1dayprogrammer20-Feb-08 7:14 
QuestionRe: code error..., in writing code to a file?? Pin
David Crow20-Feb-08 7:35
David Crow20-Feb-08 7:35 
GeneralRe: code error..., in writing code to a file?? Pin
1dayprogrammer21-Feb-08 9:17
1dayprogrammer21-Feb-08 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.