Archived

This topic is now archived and is closed to further replies.

Copying Executables with Windows Programs etc

This topic is 5852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just have a few questions about how to do certain tasks in a windows program. I investigated all of these in MSDN and came up with didly-squat. 1. Is there a way that you can make your Windows program copy itself into another folder? 2. How do you make a program run another program? 3. How, if possible, do you change the window procedure after creating the window? 4. How do you create lnk files from within a program?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Trying to build an installer? Might want to check out the Pimp software from nullsoft then.

Here are short answers to your questions.

1. Yes.
2. Use the CreateProcess or ShellExecute api''s.
3. Subclass the window.
4. Use the IShellLink COM interface.

Share this post


Link to post
Share on other sites
quote:
1. Is there a way that you can make your Windows program copy itself into another folder?

Yes.

Oh, you were expecting an explanation. Spawn/run/start another program which takes the name of your application module and a target directory as filename. That program could even be the command-line copy.

quote:
2. How do you make a program run another program?

ShellExecute()
*spawn() family of functions

quote:
3. How, if possible, do you change the window procedure after creating the window?

It might be possible through SetWindowLong(), but I sincerely doubt it. You might have to destroy and recreate the window...

quote:
4. How do you create lnk files from within a program?

a.) What are lnk files?
b.) What are you really trying to do? There may be a better way...

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
I found the ShellExecute function in MSDN. Now my question is, how would I right a program that does a command-line copy? I know how to use the copy function manually in DOS, but I don''t know how to do it from within a program. Also, is there anything I use besides ShellExecute, or just that?

Share this post


Link to post
Share on other sites
For link files: Look at the Win32 source behind libHFS. I put it under an extremely open license, so do whatever you want with it.
Remember, though, that code is in C, you''ll have to change it to have it work in C++ (due to the COM stuff being different in each). All of the vtable lines go through this process to become C++:
  
/* Original */
Fish->lpVtbl->Bob(Fish,1,2,3);
// Becomes

Fish->Bob(1,2,3);

Or you can simply use the static library I supplied for MSVC.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
masonium. first you missed S1CA answer of using CopyFile() and CopyFileEx(). second msdn docs when explaining ANY api call or function will tell you the OS it needs, headerfiles it is defined in, and the libs you can link to.

Share this post


Link to post
Share on other sites