Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - Opening files in VB (NOT with "Open FileName for Input As #number") | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
Icy Guy Red Goomba Level: 11 Posts: 17/36 EXP: 5112 For next: 873 Since: 04-21-04 From: The Matrix...er, CA, U.S.A. Since last post: 247 days Last activity: 246 days |
| ||
A while back, I recall reading somewhere that there was a way to open a file without using the method described in the thread title. Basically, what I want it to do is open a text file (let's just say it's "readme.txt") in the default text editor. To clarify... 1) User clicks "View Readme" on a menu in my program. 2) Readme file opens, as if the user had double-clicked the file in the Windows Explorer. Can someone help me out? (This time, I'm going to write this down, so I don't forget how to do this. Again. ) |
|||
Chickenlump Level: 41 Posts: 240/722 EXP: 474192 For next: 5953 Since: 03-15-04 From: Columbia City Indiana Since last post: 3 hours Last activity: 4 min. |
| ||
I have a menu item that when clicked on, opens the readme text in notepad. Private Sub Readme_Click() shellResult = Shell("notepad.exe readme.txt") End Sub And if you need other types of files to be opened, just specify the path to the program opening that file. For example : WordPad Private Sub Readme_Click() shellResult = Shell("C:\Program Files\Accessories\wordpad.exe readme.doc") End Sub And if you want the opened file to be maximized and brought to the front, do this. Private Sub Readme_Click() shellResult = Shell("notepad.exe readme.txt", vbMaximizedFocus) End Sub The readme.text or readme.doc must be in the same folder as your program for that to work (unless you specify a path to your readme, like I did with the program, works just the same. ) (edited by Chickenlump on 05-31-04 10:00 PM) (edited by Chickenlump on 05-31-04 10:02 PM) (edited by Chickenlump on 05-31-04 10:09 PM) |
|||
Icy Guy Red Goomba Level: 11 Posts: 18/36 EXP: 5112 For next: 873 Since: 04-21-04 From: The Matrix...er, CA, U.S.A. Since last post: 247 days Last activity: 246 days |
| ||
What the shell? (Ok, bad pun.) That wasn't working for me before, but looking at it now, I realize that it was because I didn't know to include the name of the app I wanted to use to open the document. Anyway, thanks for your help. |
|||
Parasyte Bullet Bill Level: 35 Posts: 28/514 EXP: 267348 For next: 12588 Since: 05-25-04 Since last post: 104 days Last activity: 32 days |
| ||
What are YOOOOUUU doing? | |||
Emptyeye Real American Level: 67 Posts: 86/2273 EXP: 2488421 For next: 104451 Since: 05-24-04 From: I DUNNOOOOOOOO!! Since last post: 9 hours Last activity: 4 hours |
| ||
Here's a delightfully random question....is there a C++ equivilent to that command? Because that would be pretty neat if so. | |||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 853/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
Originally posted by Parasyte *GASP* Parasyte making a spammy post? In C++ I think you can use system(). FYI, shell() works nice but what if the default text editor isn't Notepad? Look into the ShellExecute() API function. |
|||
Parasyte Bullet Bill Level: 35 Posts: 29/514 EXP: 267348 For next: 12588 Since: 05-25-04 Since last post: 104 days Last activity: 32 days |
| ||
Calling programs from within C\C++: http://www.cplusplus.com/ref/cstdlib/system.html Short example: #include <stdio.h> Tested with: C:\projects\system>systest.exe testfile.txt Note that the system function does not create a new thread, so the program will hang until the called program ends. But of course, under Win32, it's not so difficult to create your own thread to place the system call in. |
|||
Yarx Keese That Zelda Fanatic i am a wootest! Danicess Snuggle Slave! Fragapalooza! RTFM! Level: 20 Posts: 64/133 EXP: 37485 For next: 4954 Since: 03-15-04 From: Edmonton Since last post: 132 days Last activity: 18 days |
| ||
you can call programs ftom witnin C++ pretty easily. This uses ShellExecute(), and it will open a file that has an association with it, like a TXT file or a MP3 maybe. HEre I'm using Winver.exe cause I know you have that #include <windows.h> Using ShellExecute() in VB But it's recommended you use something that has a little more control over it such as CreateProcess(), however create process will not execute a TXT file since it is not an executable, and it will not check for associations. #include <windows.h> Using these in VB is just a matter of importing the API for them. Here's a good example project that uses both methos of starting a starting a process with VB, using the two methods I've mentioned. They are much better than the VB Shell() command. Check it out. Hope this helps (edited by Yarx on 06-02-04 05:33 PM) |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - Opening files in VB (NOT with "Open FileName for Input As #number") | | | |