|
-
Sep 21st, 2007, 08:37 AM
#1
Thread Starter
Addicted Member
[RESOLVED] could you please explain the shell execute function
hi All,
i used shell execute method once to open a word document. at that time i copied and paste the following API from some where else.
but i don't know how it works. the API is as follows..
Private Declare Function Shellexecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
could you please explain
(1):the parameters in the shell execute function.
(2): what the GetDesktopWindow will do?
Thanks:
regards:
raghunadhs
-
Sep 21st, 2007, 09:22 AM
#2
Addicted Member
Re: could you please explain the shell execute function
1) Params of ShellExecute are well explain in here.
2) GetDesktopWindow returns a window handle of the desktop.
-
Sep 21st, 2007, 09:25 AM
#3
Re: could you please explain the shell execute function
i assume, you dont have the documentation for this api or you have no idea on how to undestand the functions of a perticuler api. if i miss undestood, sorry.
There are many ways you can obtain the api documentaions.
1. if you have installd MSDN help files, you have the documentation for most of the api's vb uses.
2. MSDN Online. Just type 'Shellexecute()' or any API Function name with a () in to the Google Search Box. the first result wold be the link to the msdn online documentation. then just read the documentation there.
3. API Guide.
it has documentaion for more than 900 API's with example of each including shell execute().
After reading the documentaion of a perticuler api, some time you may not undestand some of the arguments it expects. then vbforum is the right place to put your question.
-
Sep 21st, 2007, 10:01 AM
#4
Thread Starter
Addicted Member
Re: could you please explain the shell execute function
Thanks for your immediate response. your answers helped me alot. but still i have a doubt. in the shellexecute function the last parameter is fsShowCmd. it is used to open the application window.. right? just i tried that parameter by puting various values like 1,0,2,3 ... how ever it is working as similar kind only. how can i use that parameter?
and the 5th parameter is used for the directory and by default it is "C:" means, suppose if my pc is not installed with V.B and i have an .exe file of VB application.for this purpose my application developer has to put the shellexecute's dll in the application's folder, and the path has to give in that parameter... right? or is there any some thing else?
Thanks:
regards:
raghunadhs
-
Sep 21st, 2007, 10:19 AM
#5
Re: could you please explain the shell execute function
regrding to your first question,
the fsShowCmd has the follwing in the documentation.
· nShowCmd
If lpFile specifies an executable file, nShowCmd specifies how the application is to be shown when it is opened. This parameter can be one of the following values:
SW_HIDE
Hides the window and activates another window.
SW_MAXIMIZE
Maximizes the specified window.
SW_MINIMIZE
Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE
Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW
Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT
Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window.
SW_SHOWMAXIMIZED
Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED
Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE
Displays the window as a minimized window. The active window remains active.
SW_SHOWNA
Displays the window in its current state. The active window remains active.
SW_SHOWNOACTIVATE
Displays a window in its most recent size and position. The active window remains active.
SW_SHOWNORMAL
Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
If lpFile specifies a document file, nShowCmd should be zero.
-------------end of documentation.
Now assume afte excuting a window you want that window to be maximized.
so you need to specify the SW_SHOWMAXIMIZED for the fsShowCmd parameter. to use SW_SHOWMAXIMIZED in your vb application, you need to declare it . before declaring it, you need to obtain the SW_SHOWMAXIMIZED constant value. for this u use the vb6 'API Viewer' Add-in. after obtaining the value of the SW_SHOWMAXIMIZED you simply put the following in your header section of your code.
Code:
private Const SW_SHOWMAXIMIZED = 3
now if you execute an application, the window is shown as Maximized.
-
Sep 21st, 2007, 10:37 AM
#6
Member
Re: could you please explain the shell execute function
if you just want to run some applications using shell
you can use the shell method available in VBA (VBA.shell) like following
vb Code:
Shell "notepad", vbNormalFocus
you can refer to object browser for further information
-
Sep 23rd, 2007, 12:23 PM
#7
Thread Starter
Addicted Member
Re: could you please explain the shell execute function
Hi Fazi,
it is really an excellent clarification... really it helped me alot.
Thanks:
regards:
raghunahds.v
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|