|
You can use FindFile() and FindNextFile() apis. You can refer the code snippet here[^]. You can also use CFindFile[^] which is very easy to use.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
hi experts please explain me how to add contlols to dropdown list box
in vc++
kir_MFC
|
|
|
|
|
Could you please elaborate a bit your question ?
|
|
|
|
|
Can you more explain and you need to insert controls to Listbox or ListCtrl?
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 )
|
|
|
|
|
What type of controls are you wanting to add to a listbox?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
(I sorry to put the message isue the lounge)
i create a Service progam, and use it to WinExec a other progress,
now In this progress ,CFileDialog f.OpenFile.(as saveas)
but i cant get the Desktop,
the message is "you refers to a invalid Desktop
thanks
|
|
|
|
|
Basically its not a good idea to interact with the desktop from a service. How ever I think giving the dektop interactive privilage to the service will solve your problem. To do so, select your service in the service constrol manager( "services.msc" ), take the logon tab, tick the "Allo&w service to interact with desktop" check box and restart your service.
ox0101 wrote: create a Service progam, and use it to WinExec a other progress,
WinExec function should not be used by newer applications. Please use CreateProcess() or ShellExecuteEx() functions.
|
|
|
|
|
Thats due to the fact that a "desktop object" is associated to a user session with the OS, and that a service have no "destop" since it run inside the OS behind the users.
It is in general wrong to assume that a service is running inside a user context.
What you can do is try to get who are the user that are logged on the machine, get the desktop associated to one of them and then create the process into that context.
See MSDN about "Windows Stations", "Desktop Objects" and the "CreateProcess" API.
WinExec is not the good API, since it creates the new process in the same context of its creator (that has no place to have an interactive interface, being a service).
****
On more remind: to be more productive, don't title a post in a programming forum "Help me", since it gives no clue about the nature of the help.
Imagine the forum displaying 100 posts titled "help me". Do we have to open all of them before to understand if we can helpful or not ?
A more appropriate tile may be "Process and Services", for example.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
sorry,
i will give a nice title next time
|
|
|
|
|
You can use the CreateProcessAsUser API to run the other program in the context of an interactive user.
«_Superman_»
|
|
|
|
|
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
|
|
|
|