|
Whats return value of ExitWindowsEx
|
|
|
|
|
U can't directly use this API. To use the API, u'r process should have sufficient privileges. The Privilege required is SE_SHUTDOWN_NAME. Use
OpenProcessToken() and
AdjustTokenPrivileges() to get the right privilege.
Come online at:-
jubinc@skype
|
|
|
|
|
thanks a lot...
but i'm a beginner...
can you see me an example?
sorry... and thanks too...
|
|
|
|
|
See here[^] how to use this function
|
|
|
|
|
|
thank you so much..
bye...
Giulio
|
|
|
|
|
|
ok....
This is the code... it work....
//giulio shutdown pc
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
{
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0))
{
ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF|EWX_FORCE,0);
}
}
Bye
Giulio
|
|
|
|
|
ExitWindowsEx
Windows NT/2000/XP: To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For more information about security privileges, see Privileges.
Windows 95/98/Me: ExitWindowEx does not work from a console application.
HANDLE hToken; // handle to process token
TOKEN_PRIVILEGES tkp; // pointer to token structure
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
{
return (FALSE);
}
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Get shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);
Then call ExitWindowsEx function
Known is a drop, unknown is an ocean
|
|
|
|
|
I have a partly developed MFC project. When we execute that project a window will open. In that window, a tool bar, a status bar are already created. In the status bar an idle text "Ready" is displayed in the right corner. In the left corner a pane is already there.
I also created one pane to the left of already existing pane.I do not know how they created the already existing pane. I created the second pane by specifying the ID of the second pane in the string table. Now I want to access the Properties window for the status bar(I have to). How can I do this?
|
|
|
|
|
This may not be the most helpful answer, but there *isn't* a properties window for a status bar.
If you want one when the program is running, then you'll have to subclass the status bar, handle WM_CONTEXT, and bring up your own dialog box.
What I *think* you mean is how to work out where this stuff is getting added...
Look in CMainFrame for a member variable called m_StatusBar (or similar). When you know that name, do a search for it, and you'll find any reference to it. The bits you want are probably in CMainFrame::OnCreate. You might also want to check if they're using CStatusBar, or CMyCustomMadeUpStatusBar. If they used their own bar, you'll need to dig into their class and see what it does.
Iain.
|
|
|
|
|
T.RATHA KRISHNAN wrote: I created the second pane by specifying the ID of the second pane in the string table.
Simply adding an ID to the stringtable resource will not cause a new pane to be created. You must add an item to the indicators array in the frame's code.
T.RATHA KRISHNAN wrote: Now I want to access the Properties window for the status bar(I have to). How can I do this?
Do you have an example of this?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How can I drag and drop text that user enters in the window?
Should I check if the user clicked inside the rectangle that contains the text?
Sikora
|
|
|
|
|
If u want the drag & drop of the text in edit control and within that control, then use
Rich Edit Control . Drag & Drop is built-in functionality of it.
Come online at:-
jubinc@skype
|
|
|
|
|
We have a dynamic text and we need to obtain the coordinates of the rectangle that contains the text. How can I do that? I should use the function GetTextExtent.
Sikora
|
|
|
|
|
|
Are you wanting to drag text out of a control, or drop text into a control?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Problem: i have a list (CToolTipListCtrl)
question: i want to move two or more element from a list... have you got a idea??
CODE:
void CSmartAdvertiseDlg::OnBnClickedDown()
{
if(m_cPlaylist.GetSelectedCount() == 1)
OnBnClicked(DOWN);
}
void CSmartAdvertiseDlg::OnBnClicked(int iOp)
{
POSITION Pos;
LVITEM lvi1,lvi2;
int iPos,iPeriod,iPos2,count,ret;
CString sPeriod,str1,str2;
listDataStruct *data;
lvi1.mask = LVIF_IMAGE | LVIF_TEXT;
lvi2.mask = LVIF_IMAGE | LVIF_TEXT;
if((Pos = m_cPlaylist.GetFirstSelectedItemPosition()) != NULL)
{
while(Pos)
{
iPos = m_cPlaylist.GetNextSelectedItem(Pos);
ret = sscanf(m_cPlaylist.GetItemText(iPos,2),"%d",&iPeriod);
switch (iOp)
{
case PLUS:
case MINUS:
if(ret == 1)
{
if(iOp == PLUS)
{
if(iPeriod<999)
iPeriod++;
}
else if (iPeriod)
iPeriod--;
sPeriod.Format("%d",iPeriod);
lvi1.iItem = iPos;
lvi1.iSubItem = 2;
lvi1.pszText = sPeriod.GetBuffer();
m_cPlaylist.SetItem(&lvi1);
UpdateData(FALSE);
}
else
{
//AfxMessageBox(IDS_NOT_IMAGE);
}
break;
case DOWN:
case UP:
if(iOp == UP)
iPos2=iPos-1;
else
iPos2=iPos+1;
count = m_cPlaylist.GetItemCount();
if(iPos2<0)
break;
//iPos2 = count-1;
if(iPos2==count)
break;
//iPos2=0;
for (int i = 0; i < m_wndHeader.GetItemCount(); i++)
{
lvi1.iItem = iPos;
lvi1.iSubItem = i;
lvi1.pszText = str1.GetBuffer(255);
lvi1.cchTextMax = 255;
lvi2.iItem = iPos2;
lvi2.iSubItem = i;
lvi2.pszText = str2.GetBuffer(255);
lvi2.cchTextMax = 255;
m_cPlaylist.GetItem(&lvi1);
m_cPlaylist.GetItem(&lvi2);
lvi2.iItem = iPos;
lvi1.iItem = iPos2;
m_cPlaylist.SetItem(&lvi1);
m_cPlaylist.SetItem(&lvi2);
}
data = (listDataStruct *)m_cPlaylist.GetItemData(iPos);
m_cPlaylist.SetItemData(iPos,m_cPlaylist.GetItemData(iPos2));
m_cPlaylist.SetItemData(iPos2,(DWORD_PTR)data);
m_cPlaylist.SetItemState(iPos, 0, LVIS_SELECTED);
m_cPlaylist.SetItemState(iPos2, LVIS_SELECTED, LVIS_SELECTED);
break;
}
}
m_cUpdate.EnableWindow(FALSE);
}
}
thanks, regards...
Giulio
ps. i hope that my english is comprehensible....sorry...ehhehe
|
|
|
|
|
Ing.Raiz82 wrote: question: i want to move two or more element from a list... have you got a idea??
Use the list control's DeleteItem() method.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks...
but i don't want delete the element... but i want change the position of two or more element when i click a button UP or DOWN...
bye
Giulio
|
|
|
|
|
Ing.Raiz82 wrote: but i don't want delete the element...
Technically, "move two or more element from a list" implies deleting. Moving an item up and down in the list is an entirely different matter, but easily solved. For example, to move an item up:
void CMyDialog::OnMoveUp()
{
int nIndex = m_list.GetNextItem(-1, LVNI_SELECTED);
if (nIndex >= 0)
{
CString strName = m_list.GetItemText(nIndex, 0);
m_list.DeleteItem(nIndex);
nIndex = m_list.InsertItem(nIndex - 1, strName);
}
else
ASSERT(FALSE);
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi,
I want to know what is the main what is the difference between __cdecl and __stdcall ? Can any one help regarding this.
Regards,
Chinna
|
|
|
|
|
|
A point for you from the direction Mike just pointed you,
<br />
So if you are using a function which is called twenty times, the cleanup code will be placed only once in the function called, if __stdcall is used. But if __cdecl is used, it will be twenty times in the code, i.e., everywhere in main after function is called, and if we have say fifty functions in a file each of which is called twenty times, then the size of the EXE in CDecl will be large. But then what is the advantage of __cdecl... that's something that only C has and not even C++.<br />
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
Hi,
How to change IIS Timeout in MicroSoft C++.
Regards,
Musq
|
|
|
|