|
Hi Experts,
I want to name of some API to perfome the following tasks:
1.How to Restart the system programatically?
2.API that determines system getting shutdown.
3.API that tells system is starting.
Thanx in advance.
|
|
|
|
|
pther wrote: 1.How to Restart the system programatically?
ExitWindowsEx().
pther wrote: 2.API that determines system getting shutdown.
WM_QUERYENDSESSION
pther wrote: 3.API that tells system is starting.
If the system is in starting state then how can your application be running? Or you want your application to run on startup?
|
|
|
|
|
pther wrote: 1.How to Restart the system programatically?
See ExitWindowsEx
pther wrote: 2.API that determines system getting shutdown.
See WM_QUERYENDSESSION, WM_ENDSESSION messages
pther wrote: 3.API that tells system is starting.
I dont know pal...
|
|
|
|
|
Hi all,
I am trying to create a file by my program on a path specified by user.
I want to verify this path that this path exist or not and is there a file with same name already created....Is there any api which could help me in doing this........
Thanks
|
|
|
|
|
|
|
Use CFileFind class & its member functions
this may help you.
|
|
|
|
|
PathFileExist is the api you have to use for said problem, also you have to include shlwapi.lib in your program!
"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/codeProject$$>
|
|
|
|
|
You can use of FindFirstFile for check does file exist or no.
|
|
|
|
|
I have craeted a CWinThread object for thread. This thread implements a reccurssive type function. I have used SendMessage/PostMessage functions but it is crashing. Please help me by informing exact reason and alternate solution.
|
|
|
|
|
you will have to be more specific, unless you are expecting some psychic CP member to figure out the 'exact' solution for you...
meanwhile heres a good source on threads that may help you out figure out the problem on your own:
http://www.flounder.com/workerthreads.htm[^]
|
|
|
|
|
What message are you sending?
Could you show me the code fragment?
|
|
|
|
|
I have used the following code in the procedure that run under a thread
ULONG64 ulPercent = INT64(m_ulFileCopied * 100)/INT64(ulFileSize);<br />
SendMessage(UM_PROGRESSS_INFO,(WPARAM)ulPercent,0);
In the above code while executing the SendMessage function the system is crashing. I have also used PostMessage function instead of SendMessage but the result is same.
|
|
|
|
|
I guess it may be due to the invalid window handle. You probably have no window. Try debugging the application. And when the "Abort Retry Ignore" messagebox is displayed, click Retry. Then you can locate the problem by checking call stack.
|
|
|
|
|
AFAIK CWinThread class doesn't provide a PostMessage method, you have to use the global function (supposing hWndMain is the handle of your main window):
::PostMessage(hWndMain, UM_PROGRESSS_INFO,(WPARAM)ulPercent,0);
or the PostThreadMessage method.
BTW sure that crash doesn't depend on recursion?
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.
[my articles]
|
|
|
|
|
Md. Ali Naser Khan wrote: ...but it is crashing.
Which means nothing unless you provide some sort of context, supporting information, or at least a code snippet. What exactly does "crash" mean? Is an exception thrown? Is an assertion fired? What does the call stack look like?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi All,,
I know this quetion little much non related to this forum but I found that this is much related to VC++, so I am asking for this problem's suggetion.
I am making Windows Service with help Visual Studio Windows Services Template. And as per my knowledge it uses .Net Framework.I am new at .Net Framework.
My problem is that I want to get user logon- logoff event into my service.So I decided to use LsaEnumerateLogonSessions function.For that I found that I have to use secur32.dll in my application.But how can I include this .DLL into my windows service project.So I don't know how to include this .dll into .Net Framework. Or is there any other way to use this functions into my Service application??
Thanks in Advance.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
I found from googled that we can use below staments to include this .dll and to use this function.
<br />
[DllImport ( "Secur32")] <br />
<br />
private static extern int LsaEnumerateLogonSessions(IntPtr LogonSessionCount, IntPtr LogonSessionList); private static extern int LsaEnumerateLogonSessions (IntPtr LogonSessionCount, IntPtr LogonSessionList); <br />
<br />
But I want similler to work with VC++ windows service project.
Plz help me. I have stucked into this problem.
Thanks.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
Still not getting reply from your side!!!!!!
Ok let me explore something more that what I have tried that you can understand more in this problem.
I include #include Ntsecapi.h file into my .h file (where I want to use this functions) and I try to use this function like below.but it gives me the errors as I going to show....
<br />
PULONG count;<br />
PLUID *luidptr;<br />
LsaEnumerateLogonSessions(count,luidptr);<br />
I got the errors using this function like below...
<br />
<br />
error LNK2028: unresolved token (0A000009) "extern "C" long __stdcall LsaEnumerateLogonSessions(unsigned long *,struct _LUID * *)" (?LsaEnumerateLogonSessions@@$$J18YGJPAKPAPAU_LUID@@@Z) referenced in function "public: void __clrcall CUserInfo::OnCreate(void)" (?OnCreate@CUserInfo@@$$FQ$AAMXXZ)<br />
<br />
error LNK2019: unresolved external symbol "extern "C" long __stdcall LsaEnumerateLogonSessions(unsigned long *,struct _LUID * *)" (?LsaEnumerateLogonSessions@@$$J18YGJPAKPAPAU_LUID@@@Z) referenced in function "public: void __clrcall CUserInfo::OnCreate(void)" (?OnCreate@CUserInfo@@$$FQ$AAMXXZ)<br />
<br />
fatal error LNK1120: 2 unresolved externals<br />
Plz help me. I am confused with problem.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
Have you added Secur32.lib in dependencies of the project?
Project Properties > Linker > Input > Additional Dependancies (in VS2k3)
|
|
|
|
|
Thank very much for reply.
I included that library just a minute ago you replied and it works fine.
I will contact you if I will got any problem in future.
Once again thanks.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
dear all
what happened if the case occurred below? how to correct? thanks
fatal error C1083: Cannot open include file: 'stdlib': No such file or directory
Li Zhiyuan
2/1/2008
|
|
|
|
|
You missed the point (and the following 'h').
Change
#include <stdlib>
to
#include <stdlib.h>
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.
[my articles]
|
|
|
|
|
Can you show your code for header file?
|
|
|
|
|
yes, right, i always think "libaray.h"and <library>, no .h. but actually i use fith edition of c++, it is also available for <clibrary>,thanks a lot.
Li Zhiyuan
3/1/2008
|
|
|
|