|
Is it an option to open the website in your default browser and log in to the site manually, before trying to open the link? That could work.
|
|
|
|
|
Hi all,
How can i get the handle of the the window(i.e other dialog),if it doesnt have Windows caption.
I am trying with this code,
HWND hWnd1;
hWnd1=::FindWindow(NULL,"Test");
if(hWnd1!=NULL)
{
::SetDlgItemText(hWnd1,IDOK,"sadsd");
}
If i dont have caption means,how can i change the text.If any one has any idea,please let me know
Thanks
Manju
|
|
|
|
|
Hello,
in place of NULL you can try using class name (of dialog).
otherwise, you can use EnumChildWindows(...) and GetWindowText(..) to find the appropriate window and get hwnd.
Regards,
A. Gopinath.
|
|
|
|
|
Is it custom window application, where you want to change the caption of the window or it would going to be generic one. if it custom window: you can use findwindow and findwindowex to search the window application using windowclass, otherwise follow the method told in earlier post
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I am using firefox and dreamweaver for my webprojects.
when firefox or dreamweaver is closed they take a long time clearing all the virtual memory and things like that. so mostly i invoke taskmanager and end task firefox and dreamweaver. I dont have valuable information stored neither in ff nor in dreamweaver so abnormal termination is not a problem i think.
I wanted to write a win32 api program which when executed should find firefox or dreamweaver and should terminate them abruptly like what we do as endtask using taskmanager.
So i want to know where do i have to start in the documentation of windows programing to do some thing like this.
References, suggestions, answers and external links could be useful.
Thank You.
|
|
|
|
|
system("taskkill /F /IM <processname>") should help, see if it fits your needs
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
|
I guess you're in luck. I had this same idea and wrote a piece of code, using the two documentations linked by the other poster. The following code searches for the Windows Media Player Tray Control, terminates it, and then starts it again.
I'm sure you can modify it quite easily to work for your situation.
BOOL FindTrayProcess( DWORD& pid );
void PrintError( TCHAR* msg );
int _tmain(int argc, _TCHAR* argv[])
{
DWORD pid;
HANDLE hTray;
TCHAR szPath[MAX_PATH+1] = TEXT("C:\\Program Files\\Windows Media Bonus Pack for Windows XP\\PowerToys\\mpxptray.exe");
STARTUPINFO si;
PROCESS_INFORMATION pi;
if (FindTrayProcess( pid ))
{
if (INVALID_HANDLE_VALUE == (hTray = OpenProcess( PROCESS_TERMINATE, FALSE, pid )))
{
PrintError(TEXT("OpenProcess"));
}
else
{
if ( ! TerminateProcess( hTray, 0 ) )
PrintError(TEXT("TerminateProcess"));
CloseHandle(hTray);
}
}
memset( (void*)&si, 0, sizeof(STARTUPINFO) );
si.cb = sizeof(STARTUPINFO);
memset( (void*)&pi, 0, sizeof(PROCESS_INFORMATION) );
if ( ! CreateProcess( szPath, NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi ))
{
DWORD ErrCode = GetLastError();
PrintError(TEXT("CreateProcess"));
return ErrCode;
}
CloseHandle( pi.hThread );
CloseHandle( pi.hProcess );
return 0;
}
BOOL FindTrayProcess( DWORD& pid )
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
PrintError( TEXT("CreateToolhelp32Snapshot") );
return( FALSE );
}
pe32.dwSize = sizeof( PROCESSENTRY32 );
if( !Process32First( hProcessSnap, &pe32 ) )
{
PrintError( TEXT("Process32First") );
CloseHandle( hProcessSnap );
return( FALSE );
}
do
{
if (_tcsicmp( pe32.szExeFile, TEXT("mpxptray.exe") ) == 0 )
{
pid = pe32.th32ProcessID;
CloseHandle( hProcessSnap );
return( TRUE );
}
} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle( hProcessSnap );
return( FALSE );
}
void PrintError( TCHAR* msg )
{
DWORD eNum;
TCHAR sysMsg[256];
TCHAR* p;
eNum = GetLastError( );
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, eNum,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
sysMsg, 256, NULL );
p = sysMsg;
while( ( *p > 31 ) || ( *p == 9 ) )
++p;
do { *p-- = 0; } while( ( p >= sysMsg ) &&
( ( *p == '.' ) || ( *p < 33 ) ) );
_tprintf( TEXT("\n WARNING: %s failed with error %d (%s)"), msg, eNum, sysMsg );
}
You'll need to include tlhelp32.h for the process snapshot. Hope this helps
Best Regards,
MicroVirus
|
|
|
|
|
MicroVirus wrote: I had this same idea and wrote a piece of code, using the two documentations linked by the other poster
Cool!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks or all the replies. Let me trial and error it.
|
|
|
|
|
To open a help (chm) file i use below function
ShellExecute(this->m_hWnd,_T("open"),_T("HelpSample.chm"),NULL,NULL,SW_SHOW);
and it works. But when i want to open any particular page of chm file using below function it does not work
ShellExecute(this->m_hWnd,_T("open"),_T("HelpSample.chm::/page1.html"),NULL,NULL,SW_SHOW);
Please suggest how to open any page
|
|
|
|
|
MKC002 wrote: ShellExecute(this->m_hWnd,_T("open"),_T("HelpSample.chm::/page1.html"),NULL,NULL,SW_SHOW);
Have you tried:
ShellExecute(this->m_hWnd, _T("open"), "hh.exe", _T("HelpSample.chm::/page1.html"), NULL, SW_SHOW);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Shouldn't be also _T("hh.exe") ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I'm not sure if ShellExecute() "open" will do that for you like that.
You could try something like
CreateProcess("hh.exe", " drive:\\path\\HelpSample.chm::/page1.html", ...);
*edit* or try David's method above
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If this is a help (chm) file you have created yourself, you can open any page by using the topic ID stored for that page, using function HtmlHelp().
|
|
|
|
|
This will work,
::HtmlHelp(NULL, _T("HelpSample.chm::/html/page1.html"), HH_DISPLAY_TOPIC, 0);
http://www.mono-project.com/Main_Page
|
|
|
|
|
In a list control , which is message to edit an item , like in list-control of Windows Explorer ? It's an second click , but is not double-click ... if you know what I mean ...
Thanks.
P.S. Actually , I have edit procedure on dblclick event , but this one I need to use on something else.
|
|
|
|
|
I am not sure exactly what your question is, as it is not very clear, but this[^] may be what you are looking for.
The best things in life are not things.
|
|
|
|
|
if I've perceived right, for the functionality you're expecting the list control should have the LVS_EDITLABELS list control style set. And parent window of the list control should handle LVN_ENDLABELEDIT message.
|
|
|
|
|
i think you are talking about the following situation.when we want to rename an icon in explorer we will click the item first and after a while we will click it again to rename it.is this is you are talking about?.
http://www.mono-project.com/Main_Page
|
|
|
|
|
I was talking about listcontrol behaviuour with LVS_EDITLABELS style ... I was though is there a specific windows message for that behaviour . Thank you all , guys ! You are great ! It'a always to talk with you . Best wishes !
|
|
|
|
|
While going from Paused to Stopped the Service Status Hangs at Stopping, eventually timing out and receiving an error message.
Error 1053: The service did not respond to the start or control request in a timely fashion.
Following code is causing the service to go into not responding state when going from paused to Stopped state.
Can anyone plz help me in finding out whats wrong with the code?
When I use SERVICE_CONTROL_STOP instead of SERVICE_STOP_PENDING in the method SendStatusToSCM, it resolves the issue. Is this correct way?
VOID Handler (DWORD controlCode)
{
DWORD currentState = 0;
BOOL success;
switch(controlCode)
{
// Stop the service
case SERVICE_CONTROL_STOP:
{
success = SendStatusToSCM(SERVICE_STOP_PENDING,
NO_ERROR, 0, 1, 5000);
}
break;
// Pause the service
case SERVICE_CONTROL_PAUSE:
if (runningService && !pauseService)
{
// Tell the SCM what's happening
success = SendStatusToSCM(
SERVICE_PAUSE_PENDING,
NO_ERROR, 0, 1, 1000);
pauseService = TRUE;
SuspendThread(threadHandle);
currentState = SERVICE_PAUSED;
}
break;
}
BOOL SendStatusToSCM (DWORD dwCurrentState,
DWORD dwWin32ExitCode,
DWORD dwServiceSpecificExitCode,
DWORD dwCheckPoint,
DWORD dwWaitHint)
{
BOOL success;
SERVICE_STATUS serviceStatus;
// Fill in all of the SERVICE_STATUS fields
serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
serviceStatus.dwCurrentState = dwCurrentState;
// If in the process of doing something, then accept
// no control events, else accept anything
if (dwCurrentState == SERVICE_START_PENDING)
serviceStatus.dwControlsAccepted = 0;
else
serviceStatus.dwControlsAccepted =
SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_PAUSE_CONTINUE |
SERVICE_ACCEPT_SHUTDOWN;
// if a specific exit code is defined, set up
// the win32 exit code properly
if (dwServiceSpecificExitCode == 0)
serviceStatus.dwWin32ExitCode = dwWin32ExitCode;
else
serviceStatus.dwWin32ExitCode =
ERROR_SERVICE_SPECIFIC_ERROR;
serviceStatus.dwServiceSpecificExitCode =
dwServiceSpecificExitCode;
serviceStatus.dwCheckPoint = dwCheckPoint;
serviceStatus.dwWaitHint = dwWaitHint;
// Pass the status record to the SCM
success = SetServiceStatus (serviceStatusHandle,
&serviceStatus);
return success;
}
|
|
|
|
|
When you change your service status from pause to stop, does your service main function really changing the state or exiting ?
|
|
|
|
|
I'm not even going to bother trying to read that unformatted code, but have you debugged it in the debugger? You can attach to service processes and step through and use breakpoints...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
SunilKrSingh wrote: When I use SERVICE_CONTROL_STOP instead of SERVICE_STOP_PENDING in the method
SendStatusToSCM, it resolves the issue. Is this correct way?
No.
Those two values are intended for different usages. I am not sure how you decided they were equivalent.
You use SERVICE_STOP_PENDING, while you are doing work to stop a service. Such as if you have a thread that you must wait to complet. You need to use the value SERVICE_STOPPED when the service is stopped. Just before you exit.
And the reason it appears to work is because SERVICE_CONTROL_STOP and SERVICE_STOPPED both resolve to the same integer value.
|
|
|
|
|