Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 131,510 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,853 people online right now. Registration is fast and FREE... Join Now!




Starting Another App From A Vb App

 
Reply to this topicStart new topic

Starting Another App From A Vb App

born2c0de
post 27 Mar, 2005 - 01:31 AM
Post #1


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,895



Thanked 34 times

Dream Kudos: 2800

Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions


Hey,
I know that we can start another App from VB using the ShellExecute Function in the Windows API.

But I tried opening Notepad.exe ("just for testing") using the ShellExecute Command and it doesnt start Notepad. Here's my code.
Please tell me what's wrong and How I can make it work...
and BTW...I'm calling this from a Module...specifically from Sub Main() but it doesnt work for a Form either when I make the Hwnd to Me.hwnd.

Thanx in advance.

CODE

'API Declaration

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long



CODE

retval = ShellExecute(0, _
   vbNullString, _
   "C:\windows\notepad.exe", _
   vbNullString, _
   "c:\temp", _   ' REFER [**]  
   SW_SHOWNORMAL)

'[**] Frankly, I have no idea why the directory parameter is to be given.'Please let me know about it too.


This post has been edited by born2c0de: 27 Mar, 2005 - 01:32 AM
User is offlineProfile CardPM

Go to the top of the page


tel0r
post 2 May, 2005 - 05:53 PM
Post #2


New D.I.C Head

Group Icon
Joined: 22 Feb, 2005
Posts: 27



Dream Kudos: 200
My Contributions


CODE

retval = ShellExecute(0, "", "C:\windows\notepad.exe", "", "", 1)


the nShowCmd flags are:

1 - normal window
2 - maximized
3 - maximized
4 - normal, no focus
5 - current size
8 - current size, no focus
10 - default size
User is offlineProfile CardPM

Go to the top of the page

born2c0de
post 3 May, 2005 - 03:02 AM
Post #3


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,895



Thanked 34 times

Dream Kudos: 2800

Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions


Thanks. I needed that.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 12:43AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month