|
DavidCrow wrote: I've been around long enough to know that folks don't always ask the right question.
I'm well aware of that and you are not the only one.
For the record my post wasn't meant as criticism as you seem to have understood it.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hey David,
I am sorry It was a TYPO from my side . But kindly suggest some way so that I can achieve my goal.
Kushagra
|
|
|
|
|
Kushagra Tiwari wrote: But kindly suggest some way so that I can achieve my goal.
Do you receive the message if the window is visible? What about if it's running in a non-SYSTEM account?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I have made it invisible , and I recieve this message for all accounts other than SYSTEM account and they are working pretty neat , but only for this particular case for monitering scheduled shutdowns through system account my logic goes for a toss as the message WM_QUERYENDSESSION never comes to the application.
Kushagra
|
|
|
|
|
With services, there is the "Allow service to interact with desktop" option. Is there a similar option for an app running as the SYSTEM account?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I am afraid , I did not found any thing of such kind with an application running from System account.
Kushagra
|
|
|
|
|
Does anybody knows the solution ???
Kushagra
|
|
|
|
|
You might want to also pose this question to the folks in the microsoft.public.vc.language newsgroup. Several sharp folks are active there.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
From MSDN: "Console applications receive shutdown notifications in their handler routines. To register a console handler, use the SetConsoleCtrlHandler function.
Service applications receive shutdown notifications in their handler routines. To register a service control handler, use the RegisterServiceCtrlHandlerEx function."
Maybe that helps.
|
|
|
|
|
Kushagra Tiwari wrote: I have made an MFC application with invisible window and invisible in Applications tab of taskmanager
....
I have made one instance of this executable to run in 'SYSTEM' account
Does this mean that you have created a service?
Kushagra Tiwari wrote: how to abort scheduled shutdown in Windows from an application running in system account
Are you certain that you really want to do this even if it's possible?
What do you mean by 'scheduled'?
Personally I find it suspicious that you have created an application that runs "invisible" from user perspective that aims to block the system from being brought down. I would consider it to be a very anti-social application that I wouldn't want running on any of my machines.
However, if an application calls ::ExitWindowsEx() with the EWK_FORCE parameter, WM_QUERYENDSESSION will not be sent - all processes will be terminated and possibly with data lost.
How do you distinguish from a 'scheduled' shutdown and one triggered by a user in your message handler or callback? I guess the user won't be able to bring the system down either....
What if your application runs on a machine with UPS; the power is lost and the UPS service wants to bring the system down safely? Will you block it if possible?
I guess my question really is "what are to trying to accomplish and why"? There may be a better solution.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Here is a example showed how to pass the string parameter to the javaScript function.
http://www.codeproject.com/KB/COM/jscalls.aspx
but I want to pass a userdefined data type such as a struct.
this is my code but Invoke method failed (incorrect variable type). please help me,thanks.
typedef struct
{
CComBSTR s;
int n;
}MyData;
bool CWebPage::CallJScript(const CString strFunc,CComVariant* pVarResult)
{
CComPtr<IDispatch> spScript;
if(!GetJScript(spScript))
{
ShowError(_T("Cannot GetScript"));
return false;
}
CComBSTR bstrMember(strFunc);
DISPID dispid = NULL;
HRESULT hr = spScript->GetIDsOfNames(IID_NULL,&bstrMember,1,
LOCALE_SYSTEM_DEFAULT,&dispid);
if(FAILED(hr))
{
ShowError(GetSystemErrorMessage(hr));
return false;
}
DISPPARAMS dispparams;
memset(&dispparams, 0, sizeof dispparams);
dispparams.cArgs = 1;
dispparams.rgvarg = new VARIANT[dispparams.cArgs];
SAFEARRAY *psaData = NULL;
SAFEARRAYBOUND saBound = {1,0};
MyData *pMyData = NULL;
psaData = SafeArrayCreate(VT_VARIANT,1,&saBound);
SafeArrayAccessData(psaData,reinterpret_cast<void **>(&pMyData));
pMyData[0].s = SysAllocString(L"Steve");
pMyData[0].n = 8;
SafeArrayUnaccessData(psaData);
dispparams.rgvarg[0].parray = psaData;
dispparams.rgvarg[0].vt = VT_ARRAY;
dispparams.cNamedArgs = 0;
EXCEPINFO excepInfo;
memset(&excepInfo, 0, sizeof excepInfo);
CComVariant vaResult;
UINT nArgErr = (UINT)-1;
hr = spScript->Invoke(dispid,IID_NULL,0,
DISPATCH_METHOD,&dispparams,&vaResult,&excepInfo,&nArgErr);
delete [] dispparams.rgvarg;
if(FAILED(hr))
{
ShowError(GetSystemErrorMessage(hr));
return false;
}
if(pVarResult)
{
*pVarResult = vaResult;
}
return true;
}
<script type="text/javascript">
var obj = {
string: "sss",
ints: 123
}
function showMessage(obj){
alert(obj.string);
alert(obj.ints);
}
</script>
I like c++
|
|
|
|
|
AFAIK You should pass automation-compliant types to Javascript code.
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]
|
|
|
|
|
Just have a look at this [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
hello Friends
I created a win32 based .exe tht is just reADING A TEXT FILE and deleting the file tht whatever is in tht text file but after deletion of all the files tht exe is still running in process.How can i stop that?
Thanks & Regards
Yogesh
|
|
|
|
|
Why the reading-and-deleting process doesn't terminate after its task is complete?
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 reading and deleting the process.I m reading some files and deleting it thru exe and tht exe is not getting deleted after finishing.
|
|
|
|
|
yogeshs wrote: I m not reading and deleting the process.I m reading some files and deleting it thru exe and tht exe is not getting deleted after finishing.
OK. I've already got this point. What I meant was: "have you control (i.e. the source) of the executable that reads and deletes files?" and: "cannot the executable that reads and deletes file just exit, after its task is accomplished?".
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]
|
|
|
|
|
Hey I got it.Thx for ur valuable time to solve my prob.I just ExitProcess(0)and it works.
|
|
|
|
|
yogeshs wrote: I just ExitProcess(0)and it works.
It rather appears to work... Can't you just return 0 (if it's the main function of a console app) or Post a WM_CLOSE to your app (if it's a windowed app) instead?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
How's life moving and happy Diwali to you and your family..
"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
|
|
|
|
|
Happy Diwali (whatever it is... I'm cheating: Wikipedia helped me about... ) to all you Indians (and Nepali)
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]
|
|
|
|
|
|
Life's going on, Alok. Thanks, and wish you and your family too a very happy Diwali.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Hi yogeshs,
Is your application multi-threaded?
Best Wishes,
-David Delaune
|
|
|
|
|
Post WM_CLOSE message to main window of your application.!
"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
|
|
|
|