|
Does it fail on all machines or just node129xp.radixweb.local?
What did LookupPrivilegeValue() and AdjustTokenPrivileges() return? If either of those fail, it obviously does no good to call LookupPrivilegeValue() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am checking return value after each and every WinAPI call and it doesn't fail after LookupPrivilegeValue and AdjustTokenPrivileges but fails on InitiateSystemShutdown when I use
DWORD dError = GetLastError();
Its Shows dError = 5. i.e. Access Denied.
If I give My Computer Name instead of anyone else's from my network it is working. But If I give any other Machines's name it gives above Error.
|
|
|
|
|
What happens if you use shutdown -m \\node129xp.radixweb.local -t 30 from a command prompt?
I tried your code on the two machines on my desk and it works as expected. The key difference may be that I belong to the Administrators group.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am using win2000 Service Pack 4. And When tried the command you have told me it shows the following error
'SHUTDOWN' is not recognized as an internal or external command,
operable program or batch file.
I am not able to figureout what is the problem.Do have any Idea ?
|
|
|
|
|
GauranG33 wrote: 'SHUTDOWN' is not recognized...
Sorry, it must be a Windows XP thing.
GauranG33 wrote: Do have any Idea ?
If I did, don't you reckon I would have offered it by now? Other than your own, can you shut down any PC on your network?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I tried the same code to shutdown other computers in the LAN.But it is showing the same Error Access is denied.
|
|
|
|
|
Have you ruled out your user account not having the correct privileges?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think I have the administrative rights for the computer I am working. but not sure. If you can tell me how to check will be helpful to answer correctly.
|
|
|
|
|
GauranG33 wrote: I think I have the administrative rights for the computer I am working.
Which the other (remote) computer couldn't care less about.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Then What do you think what should be the problem.I have tried to google the thing but getting the same line of code,that is not working in my case.
|
|
|
|
|
GauranG33 wrote: Then What do you think what should be the problem.
Have you considered joining the Domain Administrators group?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No I dont have Idea about that. Can you guide me through that.
|
|
|
|
|
GauranG33 wrote: No I dont have Idea about that. Can you guide me through that.
Don't you have a Network Administrator?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
I have a dialog without resources which works fine.In a class derived from CDialog I have a variable of type DLGTemplate.This variable has default x,y,cx,cy values set in the constructor.
But I want to increase the height and width of the dialog box in accordance with the number of windows controls added to the dialog box.I am adding windows controls in the OnCreate() function of Dialog class like this.
CRect Rect(10,10,100,100);
CComboBox* Combo = new CComboBox;
Combo->Create(WS_VISIBLE | WS_CHILD |CBS_SORT, Rect, this, ID);
How do I find the relation between the above Rect's coordinates and the coordinates of the dialog box?
I tried MapDialogRect but I don't understand what exactly is done there?
Please help.
Thanks
Prithaa
|
|
|
|
|
The co-ordinates specified in the control's Create() call are specified in the parent's (your dialogue's) CLIENT co-ordinates.
'Client' co-ords have their (0, 0) at the top-left of the space *within* any border and title bar the dialogue has. If it has no border and no title bar, then this is the same as the top-left of the full dialogue.
If you want to know how far the control is from the top-left of yoour dialogue and you have a title bar and / or border, then you need to get the dialogues 'window' rect, and the control's 'window' rect, and then you can calculate the offset.
Note, though, that if you ask a control for its client rect, it gives you co-ordinates relative to *its*own* client area, not its parent.
If you ask a control or window for its 'window' rect, it gicves you co-ords relative to *the*screen's* top-left.
So, to get the offset from a dialogue's client arrea to a control's top-left, do this:
CRect rctControl ;
MyControl.GetWindowRect(&rctControl);
// It's relative to top-left of screen.
MyDlg.ScreenToClient(&rctControl);
// Now, relative to top-left of dlg's client area.
To get it relative to the full dlg's top-left (ignoring title bar and border):
CRect rctControl ;
MyControl.GetWindowRect(&rctControl);
// It's relative to top-left of screen.
CRect rctDlg ;
MyDlg.GetWindowRect(&rctDlg);
rctControl.OffsetRect(rctDlg.left - rctControl.left,
rctDlg.top - rctControl.top);
// Now, relative to top-left of dlg's full area.
|
|
|
|
|
If you know your client area size, and you want to calculate the window
size that will give you that client area size, you can use:
CWnd::CalcWindowRect() (MFC)
or
AdjustWindowRect()/AdjustWindowRectEx() (Win32)
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All,
I am writing an application which checks LPT signal for doing something. My code looks like:
void LPTThread()
{
while (1)
{
if (ReadLPT(pinX) = signal level Y) {do something;}
}
//pin is one of pin of LPT port
//signal level of each pin is 0 or 1 at a time
}
This loop cause the CPU usage always 100%, is there any way to prevent it? Can we catch this change by any event handler, it mean when a change occurs at LPT or, this event handler will be called?
Thank you for your help.
|
|
|
|
|
I never heard about a function called ReadLPT (and google wasn't of any help), from where is that coming from ? Can you give more details ?
Anyway, for serial communication (so COM ports), you can use functions like WaitCommEvent. I suppose there should be something similar for you.
|
|
|
|
|
Dear Moonen,
Thank for your answer. But I need to clarify that ReadLPT is just only my pseudo code - the code that is responsible for reading LPT port signal/information.
Thanks.
|
|
|
|
|
Ok but that doesn't help. Which functions are you using exactly to access the port ?
|
|
|
|
|
Thanks for you reply. I use Inp32 function which is in the inpout32.dll library - a very common used.
|
|
|
|
|
Hi,
I don't know much about LPT signal.
but i got simmiler problem in one of my project.
you do one thing begin main thread once some where in Oninitdialog() or On InitInstance().In main thread function in while(1) loop call child thread
& do your work in child thread & you must end that childthread in that childthread itself.
have a look on given sample....
OnInitInstance()
{
begin MyMainthread()...
}
void MyMainthread()
{
while(1)
{
begin mychildthread()
::Sleep(400);
}
}
void mychildthread()
{
//Do your work here....
........
.....
_EndThread();
}
I hope this will reduce your CPU Uses.....
Rahul Vaishnav
|
|
|
|
|
Thanks for your reply.
But the problem is the thread cannot sleep every 400ms before checking LPT port. The application must ensure that, where the LPT signal changes, it will immediately handle that.
|
|
|
|
|
If the particular pin isn't one of the ones that is monitored by WaitCommEvent, there is no built-in notification mechanism. Short of writing a parallel port driver to implement notification, try putting your busy-wait loop into a seperate thread that runs at a lower priority than the rest of your program.
Judy
|
|
|
|
|
Also, you use the work "immediately" - how immediate is immediate? Windows is not a real-time OS, and as such, does not guarantee response times, even within drivers.
|
|
|
|