|
|
I want to run an application exe from another application without control of the parent application.To be clear i am running an application from pen drive.That application in the pen drive runs another application from it.now even when i closed the parent application and i am not able to safe remove the usb dtive untill i closed the child application.Any suggestions on this?
|
|
|
|
|
::ShellExecute(NULL, _T("C:\\folder\\myprog.exe"), NULL, NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
|
hi thanks for your reply.I have one question is this function run without the control of the parent application(from which we run this).
Thanks
|
|
|
|
|
yes, ShellExecute() is the API called when you double click on the icon of a programme to start it. when doing so, is your program dependant of explorer.exe ? no.
|
|
|
|
|
ya.My problem is when i used this function to run an exe from an application running in usb drive.Now when i closed the application in the usb drive,the usb is not safe removed untill i close the exe which i runned using shellexecute function.How can i resolve this?
|
|
|
|
|
radhika28 wrote: How can i resolve this?
Well, technically the drive is in use. See if this is of any help.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
radhika28 wrote: I want to run an application exe from another application without control of the parent application.
Check this out.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
in windows explorer, when we click on the icon of an image, we get to see the preview of that image. i want to do the same in my application, but have no idea of how to do it. can anyone please give me any advice on this???
thanks in advance...
vijay.
|
|
|
|
|
Where you want to show this preview on the main dialog or other dialog
|
|
|
|
|
WhiteSky wrote: Where you want to show this preview on the main dialog or other dialog
on the same dialog.
vijay.
|
|
|
|
|
So just add a static control, with the SS_BITMAP style, to your dialog's template.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: So just add a static control, with the SS_BITMAP style, to your dialog's template.
well sir, i did the same. but the static control does not display the bitmap image that i specify. However, is able to display the system icons (like Question mark Icon, or an Information Icon) .
i really dont know what mistake i am doing.
vijay.
|
|
|
|
|
CStatic has a function SetBitmap(that needs to hbitmap) but before it set Type of preperty window to Bitmap
|
|
|
|
|
vijay7173 wrote: i really dont know what mistake i am doing.
And without seeing a relevant code snippet, neither do we.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
vijay7173 wrote: same dialog
But I suggest use of foreign dialog instead same dialog you insert a CDialog to your project and show preview on that dialog if you use of this way you have more control for example you can move this window without any work or change size of show image on the dialog or insert controls to this dialog for control picture,anyway if you want to use this way on the codeproject is more articles
for example search for 3dmax,you can find an article in this article you can see behavior like 3dmax window);)
|
|
|
|
|
no, i dont want to have much features for the preview. i just need to show a thumbnail preview of the image icon selected. i dont want to provide the scaling options either. how can i do it???
vijay.
|
|
|
|
|
One good way is David Crow answer other way is use of WM_ERASEBKGND for show preview of image
|
|
|
|
|
Not problem I think its easy for you but if you have problem and I can help you you can ask;)
|
|
|
|
|
still cant get it work. below is the sample code snippet that isnt working for me.
<br />
CStatic m_ImagstBox[5];<br />
<br />
m_ImagstBox[i].Create(_T("BMP"),WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE|SS_SUNKEN,CRect(l,50,r,100), this,1001+i); <br />
<br />
m_ImagstBox[i].SetIcon(::LoadIcon(NULL,MAKEINTRESOURCE(IDI_BMP)));<br />
in the above code, IDI_BMP is the id of the icon that i want to display. but i dont know why it is not working. if i specify something like IDI_INFORMATION , then it displays the information icon in the static control.
i even tried the SetBitnap function, to display a bitmap instead of an icon. but could not get it work. below is the sample code that i had written.
<br />
m_st[i].SetBitmap(::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP_HOME)));<br />
i am new to MFC and i am sure that i am doing a mistake some where in the code. can u please point out where i am doing the mistake?
vijay.
|
|
|
|
|
You have two ways create CStatic on your code or insert Static control of ToolBox;).
But your problem check this code
m_ImagstBox[0].SetIcon(::LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_BMP)));
And same For SetBitmap
|
|
|
|
|
oh yes, now its working. I have now learnt something from that. thank u.
vijay.
|
|
|
|
|
|
I have this code and it compiles without problems in my VC++ (2003):
Includes omitted.
int main(int argc, char *argv[])
{
SOCKET s;
struct sockaddr_in saddr;
WSADATA wsadata;
short listenport;
int g = 1;
listenport = 25000;
if (WSAStartup(0x202, &wsadata) == SOCKET_ERROR)
{
printf("WSAStartup failed\n");
WSACleanup();
return 0;
}
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s == INVALID_SOCKET)
{
printf("Error opening listen socket\n");
WSACleanup();
return 0;
}
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = INADDR_ANY;
saddr.sin_port = htons(listenport);
if (bind(s,(struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) == SOCKET_ERROR)
{
printf("Bind failed\n");
closesocket(s);
s = INVALID_SOCKET;
WSACleanup();
Sleep(1000);
return 0;
}
//more irrelevant code
}
Purpose of program: Read incoming UDP packets (ints, shorts and floats mixed).
Now the question: If I just run the program and listen to port 25000 as in the code it will run through this code. But if I start another (any) program that communicates through UDP on port 25000 I will get "Bind failed" and I don't understand why from all the documentation I've read. I thought it would bind (at least as long as the communication is UDP) no matter what.
I saw the timecli and timeserv demo UDPs in this site and when I look at that code it is so similar that I can't understand why this won't work.
I hope this question is clear.
|
|
|
|
|
Maddack wrote: if (bind(s,(struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) == SOCKET_ERROR)
{
Can you check the error code it is returning ?
|
|
|
|