示例#1
0
// The commands : Select, OK & Cancel
static int Handle_VM_Command (HWND hWnd, WPARAM wParam, LPARAM lParam)
{
int wItem = (int) LOWORD (wParam);
     switch (wItem)
     {
     // Copy filename into clipboard
        case IDC_LB_SHDIR :
           if (HIWORD(wParam) == LBN_SELCHANGE)
           {char szLine [256], *p ;
            int n = (int) SendMessage ((HWND) lParam, LB_GETCURSEL, 0, 0);
             SendMessage ((HWND) lParam, LB_GETTEXT, n, (LPARAM) szLine);
             if (SendMessage ((HWND) lParam, LB_GETTEXTLEN, n, 0) >= sizeof szLine)
                       break;
             // cut string before tab
             p = strchr (szLine, '\t');
             if (p!=NULL)  *p=0;
             CopyTextToClipboard (szLine);
           }
          break;
         case IDOK :
             // fallthrough
         case IDCANCEL :
             EndDialog (hWnd, 0);
             break;
		case IDC_SD_COPY : 
             // do nothing since the file name has already been copied
             break; 
		case IDC_SD_EXPLORER : // start an explorer and close window
			 StartExplorer ();
             PostMessage (hWnd, WM_CLOSE, 0, 0);
			 break;
     } // switch wItem
return FALSE;
} // Handle_VM_Command
示例#2
0
BOOL QuitExplorer(DWORD timeout, NS_UNUSED BOOL kill)
{
    HANDLE explProc = NULL;
    nsExpData exData;

    OutputDebugString(_T("nsRE::QuitExplorer"));

    if (!(exData.explWin = FindWindow(SHELLWND, NULL)))
        NS_FAILED(explProc, _T("Cannot find explorer window"));

    GetWindowThreadProcessId(exData.explWin, &exData.pid);

    if (!(explProc = OpenProcess(SYNCHRONIZE, FALSE, exData.pid)))
        NS_FAILED(explProc, _T("Cannot open explorer proces"));

    EnumWindows(CloseExplorerWindows, (LPARAM) &exData);

    switch (WaitForSingleObject(explProc, timeout))
    {
        case WAIT_OBJECT_0: break; /* OK */
        case WAIT_ABANDONED:
            NS_FAILED(explProc, _T("WaitForSingleObject() returned Abandoned (?)"));
        case WAIT_TIMEOUT:
            if (timeout == IGNORE) break; /* OK as requested */
            if (kill)
            {
                OutputDebugString(_T("nsRE::QuitExplorer Terminating explorer"));
                TerminateProcess(explProc, 0); /* Kill the process if requested */
            }
            StartExplorer(IGNORE, FALSE); /* restart anyway or the user will have no shell */
            if (kill)
                NS_FAILED(explProc, _T("Process killed due to timeout"));
            else
                NS_FAILED(explProc, _T("Timeout while waiting for explorer process termination"));
    }

    CloseHandle(explProc);
    return TRUE;
}
示例#3
0
BOOL RestartExplorer(DWORD timeout, BOOL kill)
{
    OutputDebugString(_T("nsRE::RestartExplorer"));
    return (QuitExplorer(timeout, kill) && StartExplorer(timeout, kill));
}