|
How do I get the directory that the main exe of my app is in? I know it's probably pretty simple, but I couldn't find anything looking through the help index
|
|
|
|
|
|
|
Also try looking up GetCurrentDirectory in the MSDN help file.
|
|
|
|
|
any body could tell the correct perameters of logonuser function?
i am having a simple network of two computers and no domain i simple need passworad and user name to enter.
My service is running on one computer where i want to login and i want to login to the system using logonuser api or function but i could not successed yet.
plz tell mee correct parameters of it?
BOOL LogonUser(
LPTSTR lpszUsername,
LPTSTR lpszDomain,
LPTSTR lpszPassword,
DWORD dwLogonType,
DWORD dwLogonProvider,
PHANDLE phToken
);
r00d0034@yahoo.com
|
|
|
|
|
Notice this: The LogonUser function attempts to log a user on to the local computer. (LogonUser[^])
If you're trying to do that over the network, it won't work.
You could use OpenSCManager()[^] to open the SCM on the remote machine, then use the other Service Functions[^] to do things with the services on that machine.
|
|
|
|
|
Some years ago I made this sample program:
main (int argc, char **argv)<br />
{<br />
BOOL Successful;<br />
HANDLE AccessToken;<br />
DWORD ErrorCode;<br />
char *BufferPtr;<br />
<br />
Successful = LogonUser (argv[1], ".", argv[2], LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &AccessToken);<br />
printf ("LogonUser -> %d\n", Successful);<br />
if (!Successful)<br />
{<br />
ErrorCode = GetLastError();<br />
printf ("GetLastError -> %d\n",ErrorCode);<br />
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, ErrorCode,<br />
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &BufferPtr, 0, NULL );<br />
printf ("Error String -> %s\n",BufferPtr);<br />
free (BufferPtr);<br />
}<br />
}
However, you should have a certain privilege before you can do this (I can't remember anymore which one it was). Othwerwise you get the following error:
LogonUser -> 0<br />
GetLastError -> 1314<br />
Error String -> A required privilege is not held by the client.
Hope this helps.
Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
1) What is the result of GetLastError()?
2) What OS version, SP you are using?
The most common mistake using LogonUser() is that it needs SE_TCB_PRIVILEGE on pre-XP systems. This privilege is (and should be!) granted only to the SYSTEM account, which means that actually only service processes are able to perform a LogonUser()
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
You learn something every day. I didn't realize that XP removed the SE_TCBNAME privilege requirement from LogonUser.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
I have made an application using Dialog Boxes. I want to add a printing feature to print the whole Dialog Box.
Can u help me in this?
help me ,please
|
|
|
|
|
Check out WM_PRINT - you can use it to draw onto a printer DC.
Shog9
------
The Army's on Ecstasy, so they say -
I read all about it in USA Today.
They stepped up urine testing to make it go away,
'cause it's hard to kill the enemy on ol' MDMA...- Oysterhead
|
|
|
|
|
But my dialog's items not be drawed in OnPaint().
I use :
dc.BitBlt(0,0,100,100,GetWindowDC(),0,0,SRCCOPY);
it can not work successfully.
dc is the printer's dc here.
can u tell me the code,please!
|
|
|
|
|
This should work:
RECT rc;
GetWindowRect(&rc);
dc.BitBlt(rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,GetDC(NULL),0,0,SRCCOPY);
Of course, it will be the size of a postage stamp until you scale it, unless you have a 72 DPI printer.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
thanks.
but it can not work,too.
the printer's document is biger than 160M,and it's turning biger!
|
|
|
|
|
Goodness. It's supposed to grab the screen then print only the bits of it that contain the dialog.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Will that print the frame though ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
It should, if you pass in PRF_NONCLIENT . I've not tried it though...
Shog9
------
The Army's on Ecstasy, so they say -
I read all about it in USA Today.
They stepped up urine testing to make it go away,
'cause it's hard to kill the enemy on ol' MDMA...- Oysterhead
|
|
|
|
|
If you want to draw the entire dialog, I suspect you'll need to capture the screen, then print the part of the resultant bitmap you need. Do you want to print the dialog itself, or only it's contents ? That is, do you want to print the little x to close the window, the frame and the dialog title ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
draw the entire dialog!
i can capture the screen and save in .BMP. but the bit map has no palette. how can i print it!
|
|
|
|
|
Great - don't save it, just get the co-ordinates of the window and print only that part of it.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
thank u.
can u help me check out my code,please?
CDC *pDC=GetWindowDC();
CBitmap bm;CRect rc;GetWindowRect(rc);
int Width=rc.Width();//GetSystemMetrics(SM_CXSCREEN);
int Height=rc.Height();//GetSystemMetrics(SM_CYSCREEN);
bm.CreateCompatibleBitmap(pDC,Width,Height);
CDC tdc;tdc.CreateCompatibleDC(pDC);
CBitmap*pOld=tdc.SelectObject(&bm);
tdc.BitBlt(0,0,Width,Height,pDC,0,0,SRCCOPY);
tdc.SelectObject(pOld);
BITMAP btm;
bm.GetBitmap(&btm);
//
//here. btm can be save as BMP file
dc.StartPage(); // begin new page
Info.m_nCurPage = page;
CDC MemDC;
MemDC.CreateCompatibleDC(&dc);
pOld=MemDC.SelectObject(&bm); ///
dc.BitBlt(rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,&MemDC,0,0,SRCCOPY);
///but here .
//not be printed . the printer only print the bits,too.and the size of printer document is big!
//
|
|
|
|
|
This all looks right, I don't get what the problem is. What are the bounds of the bitmap ? Have you tried blting it to the screen ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
yes.
i have tested it.it can be bited to the screen.
my printer is canon lbp_800.
it's my printer's problem?
|
|
|
|
|
It's odd, because in theory if you send a 800x600 bitmap to a printer, you should expect to get a very small bitmap, because most printers have at least 600 dots per inch. IF the bitmap is fine, and the printer driver is hanging with a large amount of data passing through, then the problem is most certainly the print code.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
then,
how can i do?
save as BMP file,and print it with MS paint?
please
|
|
|
|
|