Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-22-2002, 11:06 AM   PM User | #1
scroots
Senior Coder

 
Join Date: Jun 2002
Location: UK
Posts: 1,137
Thanks: 0
Thanked 0 Times in 0 Posts
scroots is an unknown quantity at this point
VB /C++ tutorials

does anyone know of any VB/C++ tutorials which will teach me how i can link a button to a program. So when the button labeled notepad is clicked it opens C:\blah\notepad.exe
i`m interessed in using either one of the two languages for it.
do you understand?

thanks in advance

scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
scroots is offline   Reply With Quote
Old 09-22-2002, 04:00 PM   PM User | #2
maes
Regular Coder

 
Join Date: Jul 2002
Location: Belgium
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
maes is an unknown quantity at this point
I assume you're programming for windows:
Try this:
Code:
switch(LOWORD(wParam))
{		
case BUTTON:
      ShellExecute(hwnd,"open","c:\\winnt\\system32\\notepad.exe",NULL,NULL,SW_MAXIMIZE);
return 0;
}

if you're programming for the console (I think this also works in linux)
you can also use
Code:
#include <process.h>
...
spawnl(_P_WAIT,"c:\\winnt\\system32\\notepad.exe","c:\\winnt\\system32\\notepad.exe",NULL);

- Maes
maes is offline   Reply With Quote
Old 09-22-2002, 04:14 PM   PM User | #3
scroots
Senior Coder

 
Join Date: Jun 2002
Location: UK
Posts: 1,137
Thanks: 0
Thanked 0 Times in 0 Posts
scroots is an unknown quantity at this point
maes could you expalin a little deeper.

scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
scroots is offline   Reply With Quote
Old 09-22-2002, 04:36 PM   PM User | #4
maes
Regular Coder

 
Join Date: Jul 2002
Location: Belgium
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
maes is an unknown quantity at this point
Well, when you're makeing a win32 (C) aplication, I advice you to use ShellExecute .

With ShellExecute, you can start an other program or an other document, print it, etc.
the first parameter is the Handle to your window (HWND)

the second: this is what you want to do with the program/document. we want to "open" it. this will execute the .exe-file.

the third: this is the file (+path) we want to execute.
you have to youse "\\" instead of '\' beacause the slash (or backslash whatever) is an escape character

fourth: these are the parameters you want to give to your exe program. I've used NULL here this means I don't want to pass any arguments. but you can type here a path to a .txt-file that you want notepad to open

fifth: this is the default directory. when you add an .txt-file as the fourth parameter, you can specifie here where notepad has to look for it.

sixth: this specifies how the program will be shown to you.
I used SW_MAXIMIZE: this will maximize notedpad.
SW_MINIMIZE will minimize notepad. there are some more styles, but these are the most important ones (IMHO)


Am I makeing any sense here?
maes is offline   Reply With Quote
Old 10-06-2002, 01:56 PM   PM User | #5
scroots
Senior Coder

 
Join Date: Jun 2002
Location: UK
Posts: 1,137
Thanks: 0
Thanked 0 Times in 0 Posts
scroots is an unknown quantity at this point
are there any tutorials on this, as i am not the worlds best c++/VB programmer, infact i don`t know much at all.
or what should my code look like?
cheers
scroots
__________________
Spammers next time you spam me consider the implications:
(1) that you will be persuaded by me(in a legitimate mannor)
(2)It is worthless to you, when i have finished
scroots is offline   Reply With Quote
Old 10-08-2002, 02:10 AM   PM User | #6
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,890
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
PHP Code:
<?
#include <shlobj.h>
#include <shlwapi.h>

#define YAKS "C:\\WINNT\\NOTEPAD.EXE"

main()
{
    
HWND handle;
    
ShellExecute(handle,"open",YAKS,NULL,NULL,SW_SHOWNORMAL);

    return 
0;
}
?>
lol - just wanted to see what the PHP syntax highlighting did to C
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 07-29-2005, 06:25 PM   PM User | #7
arturion
New to the CF scene

 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
arturion is an unknown quantity at this point
Question Is it possible to use a relative path?



Is there a way to use a relative path, instead of writing the complete path?

For example, if I have a executable.exe file in a folder

Can I use:

"folder\\executable.exe"

instead of

"d:\\folder\\executable.exe"

?

Because I´m gonna save the program that calls the file "executable.exe" in a CD, and the drive could have another letter assigned instead of "d:"

Thanks
arturion is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:35 AM.


Advertisement
Log in to turn off these ads.