|
if you want to this, the service has to run under a user account. But this isnt right. A serivce hasnt anything to do on a desktop of a user. Use the "All User" Directories for output.
Greetings from Germany
|
|
|
|
|
thank everyone,
sometimes i cant express my mind
the title is "CFileDialog in Windows Service"
i cant get the loged user's Desktop
Now i find a method,but it's my result i want to get
the fllowing:
PSID psidEveryone;
// Create a SID for the built-in "Everyone" group
SID_IDENTIFIER_AUTHORITY sidAuth = SECURITY_WORLD_SID_AUTHORITY;
if (!AllocateAndInitializeSid( &sidAuth, 1, SECURITY_WORLD_RID,
0, 0, 0, 0, 0, 0, 0, &psidEveryone )){
// Error
}
HWINSTA hWinSta = GetProcessWindowStation();
if (hWinSta == NULL){
// Error
}
AllowAccessToWinSta(psidEveryone,hWinSta);
HDESK hDesk = GetThreadDesktop(GetCurrentThreadId());
if (hDesk == NULL){
// Error
}
(from Jerry Richer 's Program Service-Side Windows)
|
|
|
|
|
How Can use it?
i put it in my ON_BN_CLICK
example:(i still dont get the loged user's desktop )
PSID psidEveryone; <br />
<br />
SID_IDENTIFIER_AUTHORITY sidAuth = SECURITY_WORLD_SID_AUTHORITY;<br />
if (!AllocateAndInitializeSid( &sidAuth, 1, SECURITY_WORLD_RID, <br />
0, 0, 0, 0, 0, 0, 0, &psidEveryone )){<br />
}<br />
<br />
HWINSTA hWinSta = GetProcessWindowStation();<br />
if (hWinSta == NULL){<br />
}<br />
AllowAccessToWinSta(psidEveryone,hWinSta);<br />
<br />
HDESK hDesk = GetThreadDesktop(GetCurrentThreadId());<br />
if (hDesk == NULL){<br />
}<br />
<br />
<br />
<br />
STARTUPINFO startinfo;<br />
RtlZeroMemory(&startinfo,sizeof(STARTUPINFO));<br />
startinfo.cb=sizeof(STARTUPINFO);<br />
startinfo.lpReserved = NULL;<br />
startinfo.lpReserved2 = NULL; <br />
startinfo.cbReserved2 = 0;<br />
startinfo.lpDesktop = NULL; <br />
startinfo.dwFlags = 0;<br />
PROCESS_INFORMATION pinfo;<br />
RtlZeroMemory(&pinfo,sizeof(PROCESS_INFORMATION));<br />
CreateProcess(NULL,<br />
_T("E:\\work\\work\\InspectnPro\\InspectnPro\\debug\\InspectnPro.exe"),<br />
NULL,<br />
NULL,<br />
TRUE,<br />
NULL,<br />
NULL,<br />
NULL,<br />
&startinfo,<br />
&pinfo);
|
|
|
|
|
How I can Move dailog box by clicking anywhere not only on caption bar?
Thanks .
|
|
|
|
|
sampat wrote: How I can Move dailog box by clicking anywhere not only on caption bar?
Handle the LButtonDown message and send the WM_NCLBUTTONDOWN, message from it as follows
void CMYDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
SendMessage( WM_NCLBUTTONDOWN, HTCAPTION, (LPARAM) MAKELPARAM( point.x, point.y) );
CDialog::OnLButtonDown(nFlags, point);
}
|
|
|
|
|
Thanx buddy .... everything is solved
|
|
|
|
|
The solution given by NS is the right way to do it.
«_Superman_»
|
|
|
|
|
Like this...
UINT CTestDlg::OnNcHitTest(CPoint point)
{
return HTCAPTION;
}
But if you want to be more specific, try the following... it will exclude the borders, menu, etc.
UINT CTestDlg::OnNcHitTest(CPoint point)
{
UINT uHitTest = CDialog::OnNcHitTest(point);
if( uHitTest == HTCLIENT ) return HTCAPTION;
}
- ns -
|
|
|
|
|
Paul DiLascia's article[^] will be interesting.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi ,I am new in mfc and c++, and currently I have got problem with this kind of error
basically , i have to file get.cpp and send.cpp
and i want to share variable across that files
and i thought we can use keyword "extern"
so here is my code
in send.h
int g_iEnabled
class csend
{
......
}
in get.h
extern int g_iEnabled
class cget
{
....
}
is that the rightway to share variable across multiple files
thanks for your help
bye
|
|
|
|
|
Put the int g_iEnabled declaration in the .cpp file.
«_Superman_»
|
|
|
|
|
Hi thanks men for the solution, it works perfectly
|
|
|
|
|
Hi all,
The question might be strange, but I have a MFC application (say on client system) which will be started by another program from another system (say server) using PsTools command via network. Both systems are connected using a crossover cable and once the server starts the client program it sends commands to client as per user request on server program (which is also a MFC program). The client program is multi-threaded program and records/playbacks videos from framegrabber. Everything is fine for a while, but recently the client program started acting weird, the program closes abruptly without any warning or message or anything, it just disappears (not even its trace in task manager) while the server is still running, the client should close only when the server sends a quit ('Q') command. I tried to have a message pop up in 'OnClose()' function etc etc, but nothing works, it just disappears randomly.
I wonder if there is any way to figure out what the problem/error is, any suggestions??
thanks,
-PNT.
PKNT
|
|
|
|
|
I've seen this happen when an exception is raised and the EXCEPTION_REGISTRATION linked list is corrupt. See here[^] for more information. The following program demonstrates this (it's from memory so bear with me):
void main()
{
__asm
{
mov eax, 0
mov FS:[0], eax
}
*(char*)0 = 0;
return 0;
}
Steve
|
|
|
|
|
In addition to what Stephen Hewitt pointed out... there are other situations which may cause the symptoms you are describing. For example... if you have a global structured exception handler and a second exception occurs while inside your handler code... the application will simply be terminated and would 'dissapear'.
Another situation which would cause the application to 'just dissapear' would be calling:
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
This single line of code would cause the application to simply dissapear when an exception occured.
I would suggest downloading Debugging Tools for Windows[^] and attaching WinDbg to a debug build of your application.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks for your replies, I thought of using WinDbg, but couldnt figure out exactly how to use it. But will check out for some articles on it. BTW in my program there are no stacks or heavy memory allocations or anything memory intensive, its just get the frame data from framegrabber and write it to a raw avi file on the hard drive.
Will try WinDbg to find the problem.
-PNT
PKNT
|
|
|
|
|
Kiran Satish wrote: there are no stacks
Yes there is: simply calling a function and using local variables uses the CPU's stack. This is the same stack that holds the EXCEPTION_REGISTRATION linked list.
Steve
|
|
|
|
|
I tried to use WinDbg while running this application but its gives me .pdb file not found or mismatched error. I recompiled the program in debug mode and tried to run again and it gave me the same error.
Are there any settings that needs to be set in project options of the applicaiton in debug mode??
-PNT
PKNT
|
|
|
|
|
|
That option "Generate Debug Info" is always enabled in my applications in debug mode. Will go through the PDB files article in a min.
I found a problem/unhandled exception wihtin the application relating to CComVariant. As I said my application communicates with another system using ethernet while at the same time it communicates with another program within the system using COM port. Inorder to handle the events from COM port (CMSComm object), I use a CComVariant object to read the data from CMSComm object whenever it triggers OnReceiveMessage() event. This is how I have used it in my program -
void CMyApplicationDlg::OnReceiveMessage()
{
if(m_ComRecCommand.GetCommEvent() == 2)
{
CString buffer,vidname,val;
m_cvRespInput.Clear();
m_cvRespInput = m_ComRecCommand.GetInput();
buffer = m_cvRespInput.bstrVal;
}
}
It gives me error at line 8, when I watch the variable in debug mode, it shows VT_ERROR for CComVariant object. This is not the case before using ethernet communication from another system. But once I use it, this one shows only VT_ERROR. Am confused on understanding why this is happening???
PKNT
modified on Thursday, January 15, 2009 8:56 PM
|
|
|
|
|
Kiran Satish wrote: when I watch the variable in debug mode, it shows VT_ERROR for CComVariant object.
What is the m_cvRespInput.scode (status code) value? It should be giving you an error code.
Best Wishes,
-David Delaune
|
|
|
|
|
|
...
"Well, we're getting "F"'d at work. WPF, WCF, and WWF... WTF?" --John Simmons
|
|
|
|
|
Would all 5.8 million of you members, plus those few programmers who aren't members yet, please be so kind as to read my excellent article, vote it 5, bookmark it and download the code provided?
TIA
|
|
|
|
|
But 5 of left or right ?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|