|
Due to poor network connection, sometimes the page does not fully load when I call Navigate. My code performs certain task after the entire page has done loading. Does anyone know if there is a default timeout for Navigate? If not, is there an elegant way to wait for a while before I call Navigate again? I could create a thread to monitor if my OnDocumentComplete function has been called but I am hoping for another way.
|
|
|
|
|
I am answering my own post but I don't think starting a thread and checking to see whether the page has done loading periodically will work because the Navigate call is single-threaded.
|
|
|
|
|
Try this
BOOL m_bReady = 0;
BSTR bsStatus;
CString str;
m_pBrowser->Navigate2(vaURL,null,null,null,null) ;
while(!m_bReady)
{
m_pBrowser->get_StatusText(&bsStatus);
mStr = bsStatus;
if(mStr == "Done") m_bReady=1;
}
|
|
|
|
|
Thanks for the reply. But as I was trying to say with my second post, the browser functions are single-threaded so the while-loop will go into an infinite loop since Navigate2 won't get a chance to run. As far as I know, the only way to check if the page has finished loading or not is to write a call-back function.
|
|
|
|
|
I am creating an appcation on Vista,which include a service and an application .
(i am a new comer)
In my service i am creating an event and waits for that event.In application i am opening the same event and calling setevent function(problem starts here). In service ,its not getting the setevent notification.i searched in the net and saw something about integrity level.its telling that service and applicaation got differnt integrity level.
So it will be very helpfull if you tell how to do the IPC between a service and an application in Vista
Thanks in advance
Navaneeth
|
|
|
|
|
Can you show the code you use to create the event (both sides)?
Also how are you checking if the event is signaled in the service?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
here the service creates the event and wait for the event to occur.
using WaitForSingleObject ,i am checking in the service as shown bellow
service
DWORD
WINAPI IpcThread(LPVOID lpParam)
{
HANDLE ghRequestEvent = NULL ;
ghRequestEvent = CreateEvent(NULL, FALSE,
FALSE, "Global\\Role_Set") ; //creating the event
if(NULL == ghRequestEvent)
{
//error
}
while(1)
{
WaitForSingleObject(ghRequestEvent, INFINITE) //waiting for the event
//here some action related to event
}
}
Application
Here in application ,opening the event and seting the event
unsigned int
event_notification()
{
HANDLE ghRequestEvent = NULL ;
ghRequestEvent = OpenEvent(SYNCHRONIZE|EVENT_MODIFY_STATE, FALSE, "Global\\Role_Set") ;
if(NULL == ghRequestEvent)
{
//error
}
SetEvent(ghRequestEvent) ;
}
this is the code i wrote.waiting for your responce
Thanks & Regards
Navaneeth
modified on Wednesday, September 24, 2008 2:47 AM
|
|
|
|
|
navaneethm wrote: ghRequestEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, "Role_Set") ;
Does it work if you use
ghRequestEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, "Global\\ Role_Set") ;
instead?
If not, is OpenEvent() succeeding?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mr.Mark Salsbery for showing the intrest and helping me.
Yes i changed accordingly (i used "Global" in both application.please see the updated code).
The error i am getting in console application (where i am opening the event) is error no 5(Access is denied. ) .
i am running both application(serivce and console application) with administrative privilege (i logged in as Administraor and running the console application by right clicking and using the option "run as administrator") .
i am looking forward for your reply
Thanks & Regards
Navaneeth
|
|
|
|
|
You may want to look carefully at the event access rights.
You don't need EVENT_ALL_ACCESS.
EVENT_MODIFY_STATE is the only access your app needs.
You certainly shouldn't have to run with elevated privileges just
to get a handle to a global event object
Synchronization Object Security and Access Rights[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have tried that way also ( SYNCHRONIZE | EVENT_MODIFY_STATE ,etc ),i am getting the same error 5.
|
|
|
|
|
I don't know what you have going on.
I just tried the following on Vista (not running elevated)...
HANDLE ghRequestEvent = ::CreateEvent(NULL, FALSE, FALSE, _T("Global\\Role_Set")) ;
if(NULL == ghRequestEvent)
{
return;
}
::WaitForSingleObject(ghRequestEvent, INFINITE);
::CloseHandle(ghRequestEvent);
HANDLE ghRequestEvent = ::OpenEvent(EVENT_MODIFY_STATE, FALSE, _T("Global\\Role_Set"));
if(NULL == ghRequestEvent)
{
DWORD dwErr = ::GetLastError();
return;
}
::SetEvent(ghRequestEvent);
::CloseHandle(ghRequestEvent);
Worked fine first try.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Is the first application a service ?
|
|
|
|
|
navaneethm wrote: Is the first application a service ?
No, but I'll test that as well - I'll get back to you shortly
on that
What account is your service running under?
Also, I used OpenEvent( EVENT_MODIFY_STATE, not OpenEvent( SYNCHRONIZE|EVENT_MODIFY_STATE.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
OK got it. Here's code that works on Vista with the event
created in a service:
SECURITY_DESCRIPTOR sd = {0};
::InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
::SetSecurityDescriptorDacl(&sd, TRUE, 0, FALSE);
SECURITY_ATTRIBUTES sa = {0};
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = &sd;
HANDLE ghRequestEvent = ::CreateEvent(&sa, FALSE, FALSE, _T("Global\\Role_Set")) ;
if(NULL == ghRequestEvent)
{
return;
}
::WaitForSingleObject(ghRequestEvent, INFINITE);
::CloseHandle(ghRequestEvent);
HANDLE ghRequestEvent = ::OpenEvent(EVENT_MODIFY_STATE, FALSE, _T("Global\\Role_Set"));
if(NULL == ghRequestEvent)
{
return;
}
::SetEvent(ghRequestEvent);
::CloseHandle(ghRequestEvent);
I would expect OpenEvent() to return NULL with GetLastError returning an access
denied error but instead it returns a valid handle that does nothing when you use it.
SetEvent() succeeds as well.
Hopefully that will work for you
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you Mr.Mark Salsbery,
Thank you very much
The problem solved with your help.
Thanks & Regards
Navaneeth
|
|
|
|
|
i made a sample service and a console application for testing .i am putting complete code bellow.
Service ( Application 1)
#include <windows.h>
SERVICE_STATUS FireServiceStatus;
SERVICE_STATUS_HANDLE FireServiceStatusHandle;
HANDLE hevent;
HANDLE hFile;
HANDLE ghTestEvent;
HANDLE ghIPCthread = NULL ;
void WINAPI ServiceMain(DWORD argc, LPTSTR* argv);
void ServiceInstall();
DWORD WINAPI Ipcthread(LPVOID lpParam);
void servicestop();
void WINAPI FireServiceHandler(DWORD dwctrl);
VOID CALLBACK ApcProc(ULONG_PTR dwparam)
{
}
void __cdecl _tmain(int argc, _TCHAR* argv[])
{
if(lstrcmpi(argv[1],TEXT("Install"))==0)
{
ServiceInstall();
return;
}
SERVICE_TABLE_ENTRY DispatchTable[] = {{TEXT("SampleService"),ServiceMain},{NULL,NULL} };
if(!StartServiceCtrlDispatcher(DispatchTable))
{
}
}
void WINAPI ServiceMain(DWORD argc, LPTSTR* argv)
{
FireServiceStatus.dwCheckPoint = 1;
FireServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_SHUTDOWN ;
FireServiceStatus.dwCurrentState = SERVICE_START_PENDING;
FireServiceStatus.dwServiceSpecificExitCode = 0;
FireServiceStatus.dwServiceType = SERVICE_WIN32;
FireServiceStatus.dwWaitHint = 3000;
FireServiceStatus.dwWin32ExitCode = 0;
FireServiceStatusHandle = RegisterServiceCtrlHandler(TEXT("SampleService"),FireServiceHandler);
if(!FireServiceStatusHandle )
{
goto cleanup;
}
if(!SetServiceStatus(FireServiceStatusHandle,&FireServiceStatus))
{
goto cleanup;
}
FireServiceStatus.dwCheckPoint = 0;
FireServiceStatus.dwCurrentState = SERVICE_RUNNING;
FireServiceStatus.dwWaitHint = 0;
FireServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_SHUTDOWN ;
SetServiceStatus(FireServiceStatusHandle,&FireServiceStatus);
ghIPCthread = CreateThread(NULL,0,Ipcthread,NULL,0,NULL);
servicestop();
cleanup:
FireServiceStatus.dwCheckPoint = 0;
FireServiceStatus.dwCurrentState = SERVICE_STOP;
FireServiceStatus.dwWaitHint = 0;
SetServiceStatus(FireServiceStatusHandle,&FireServiceStatus);
if( ghIPCthread == NULL)
{
QueueUserAPC(ApcProc,ghIPCthread,NULL);
ghIPCthread = NULL;
}
}
DWORD WINAPI Ipcthread(LPVOID lpParam)
{
HANDLE ghTestEvent;
TCHAR buf[50];
DWORD err;
hFile = CreateFile( TEXT("D:\\eventerror.txt"),
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
ghTestEvent = CreateEvent(NULL,FALSE,FALSE,TEXT("Global\\sampleEvent"));
if(ghTestEvent == NULL)
{
wsprintf(buf,TEXT("CreateEvent failed %d"),GetLastError());
WriteFile(hFile,buf,sizeof(buf),NULL,NULL);
RtlZeroMemory(buf,sizeof(buf));
goto Cleanup;
}
err = WaitForSingleObject(ghTestEvent,INFINITE);
if( err == WAIT_FAILED)
{
wsprintf(buf, TEXT("WaitForSingleObject failed %d"),GetLastError());
WriteFile(hFile,buf,sizeof(buf),NULL,NULL);
RtlZeroMemory(buf,sizeof(buf));
goto Cleanup;
}
wsprintf(buf, TEXT("WaitForSingleObject Success:Got the event") );
WriteFile(hFile,buf,sizeof(buf),NULL,NULL);
RtlZeroMemory(buf,sizeof(buf));
Cleanup:
CloseHandle(ghTestEvent);
CloseHandle(hFile);
return err;
}
void ServiceInstall()
{
SC_HANDLE sc_manager;
SC_HANDLE sc_service;
TCHAR szPath[MAX_PATH];
if(GetModuleFileName(NULL,szPath,MAX_PATH))
{
printf("GetModuleFileName failed %d",GetLastError());
}
sc_manager = OpenSCManager( NULL,NULL,SC_MANAGER_ALL_ACCESS);
if(sc_manager == NULL)
{
printf("openSCManager failed with error code %d \n",GetLastError());
return;
}
sc_service = CreateService( sc_manager,
TEXT("SampleService"),
TEXT("SampleService"),
SERVICE_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
szPath,
NULL,
NULL,
NULL,
NULL,
NULL );
if( sc_service == NULL )
{
printf("Create service failed %d\n",GetLastError());
CloseServiceHandle(sc_manager);
return;
}
else
printf("service installed successfully\n");
CloseServiceHandle(sc_service);
CloseServiceHandle(sc_manager);
}
void WINAPI FireServiceHandler(DWORD dwCtrl)
{
switch(dwCtrl)
{
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
FireServiceStatus.dwCheckPoint = 0;
FireServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
FireServiceStatus.dwWaitHint = 0;
FireServiceStatus.dwControlsAccepted = 0 ;
SetServiceStatus(FireServiceStatusHandle,&FireServiceStatus);
SetEvent(hevent);
break;
case SERVICE_CONTROL_INTERROGATE:
break;
default:
break;
}
return ;
}
void servicestop()
{
hevent=CreateEvent(NULL,TRUE,FALSE,NULL);
while(1)
{
WaitForSingleObject(hevent,INFINITE);
FireServiceStatus.dwCheckPoint = 0;
FireServiceStatus.dwCurrentState = SERVICE_STOPPED;
FireServiceStatus.dwWaitHint = 0;
SetServiceStatus(FireServiceStatusHandle,&FireServiceStatus);
return;
}
}</windows.h>
Console Application (Application 2)
#include<windows.h>
#include<stdio.h>
#include<tchar.h>
int main()
{
HANDLE ghEvent;
BOOL res;
ghEvent = OpenEvent( SYNCHRONIZE|EVENT_MODIFY_STATE , FALSE, TEXT("Global\\sampleEvent"));
if (ghEvent == NULL)
{
printf("error on opening the event %d ",GetLastError());
getchar();
return 1;
}
res = SetEvent(ghEvent);
if(!res)
{
printf("SetEvent failed,%d",GetLastError());
getchar();
return 1;
}
printf("SetEvent success\n");
return 0;
}
|
|
|
|
|
I'm working on an antivirus software application. I would like to know how can we send or install the updates to the client systems through sever system remotely using VC++ and COM. Is it possible without using COM??? I'm working on VC7.1
|
|
|
|
|
brucewayn wrote: I would like to know how can we send or install the updates to the client systems through sever system remotely using VC++ and COM. Is it possible without using COM??? I'm working on VC7.1
Please read the guidelines[^]. If you pin point a specific technical problem and ask how to solve it, someone may answer you.
But with this question, there won't be much of luck.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Thanks Rajesh for reminding me the guidelines however I truly feel that my question is straight forward. i would like to know how can we send or install the updates to the client systems through sever system remotely using VC++ and COM.I did try using Windows Management Instrumentation (WMI) however i realized that with WMI we can see the process in the client sever but we can't install the updates. I hope you had got some idea about what i required and i'm quite sure that you would come out with some good solution.
|
|
|
|
|
I would agree on the fact that the question is pretty much straight forward. I meant to tell that you have not even decided on an approach on how to go about it. But if the approach is what you wanted opinions on, then fair enough.
You mentioned that you wouldn't want to use COM in your original post, so you could try sockets? It does not look like a good idea if installation or some kind of 'push' activity happens from the server side. This design could be troublesome, as the client may not be ready all the time.
A better approach would be to make the client 'poll' for updates on a regular interval. If there is an update available, the client could request a download from the server, get it and do a ShellExecute() or something, as per the design to apply the latest updates.
This way, the user would get an option to specify when should the updates happen.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Hello !
I am working on an MFC dialog based project from past few days, today i tried to add a combobox ( or button , etc) to my dialog it gives the following message :
Add/Remove operation is impossible, because code element "MyDlg" is read only
i also checked the properties of my file, it was selected read only, i disabled it. Again i checked it it automatically selects to "Read only".
is there any solution to this problem !!
|
|
|
|
|
|
Hai all,
In my project I have used many dialog boxes. When I call tree control in one of the dialog boxes I get a Debug assertion failure (In dlgdata.cpp at the location ASSERT(!pDX->m_bSaveAndValidate); line number 636). Please any one help me.
Thanks and Regards
Bhanu
|
|
|
|
|
What are you trying to do ? Please, post some relevant code. Did you try debugging to see what is going on ?
|
|
|
|
|