/**********************************************************************
此函数用于传入一个完整路径来启动程序
***********************************************************************/
int CStartAllDlg::StartProcess(char *szPath)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
szPath, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
return -1;
}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}
#define ZTE_NOTES_PATH "C://Program Files//lotus//notes//notes"
#define ZTE_NOTES_PSWD "your pwd"
/**********************************************************************
此函数用于传入一个完整路径来启动程序
***********************************************************************/
void CStartAllDlg::OnNotes()
{
// TODO: Add your control notification handler code here
HWND pHandle;
HWND cHandle;
int count;
StartProcess(ZTE_NOTES_PATH);
/* Note启时间20秒 */
count = 400;
do
{
Sleep(50);
pHandle = ::FindWindow(NULL, "Lotus Notes");
cHandle = ::FindWindowEx(pHandle, NULL, "IRIS.password", NULL);
count--;
} while((pHandle == 0 || cHandle == 0) && count);
if (pHandle == 0 || cHandle == 0)
{
return;
}
::SendMessage(cHandle, WM_SETTEXT, NULL, (long)ZTE_NOTES_PSWD);
cHandle = FindWindowEx(pHandle, NULL, NULL, "确定");
::SendMessage(cHandle, BM_CLICK, NULL, NULL);
}