f



Getting handle on Handles?

I'm trying to create my own shellexecute program named shell4OD and am
having problems with handles.  Here is my code ...
=====
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

Public function Shell4OD( byVal cmd as string, byVal parameters as
string, byVal Dir as string, byVal showHide as integer) As Boolean
   Dim procHandle As Long, shellHnd As Long, taskID As Long

' hmmm  shellHnd = ????	<=== here is my problem

        taskID = ShellExecute( shellHnd, _
             vbNull,  cmd,  parameters, Dir, showHide)
        ' get the process handle
        procHandle = OpenProcess(&H100000, True, taskID)
        Shell4OD = WaitForProcess( procHandle)
        ' close the handle
        CloseHandle procHandle
end function

' Wait for a number of milliseconds, and return the running status
' of a process.  If argument is omitted, wait untill the process
'  terminates.
Function WaitForProcess(taskId As Long, Optional msecs As Long = -1) _
    As Boolean
        Dim procHandle As Long
        ' get the process handle
        procHandle = OpenProcess(&H100000, True, taskId)
        ' check for its signaled status, return to caller
        WaitForProcess = WaitForSingleObject(procHandle, msecs) <> -1
        ' close the handle
        CloseHandle procHandle
End Function
====== end of code ====

0
10/7/2003 9:16:05 PM
comp.lang.visual.basic 2233 articles. 0 followers. please859 (33) is leader. Post Follow

1 Replies
475 Views

Similar Articles

[PageSpeed] 56

The first parameter of ShellExecute should be the handle of the window to 
which dialog boxes thrown by the call are owned. Normally, most people use 
GetDesktopWindow() to make the desktop the owner of any dialogs. You can, if 
you prefer, use the hwnd of your form .. it really doesn't matter to the 
call. The only 'issue' is that if the desktop is the owner and an error 
dialog is thrown on starting, your users could click your app which would 
gain focus, possibly covering the error dialog. Making the form own the 
dialogs causes them to be displayed modally to your application, preventing 
inadvertent switching away.

-- 

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.


"Phil B Brubaker" <philBru@Lanset.com> wrote in message 
news:3ds5ovsccaof56eumhopkpin9pl1t9mol6@4ax.com...
: I'm trying to create my own shellexecute program named shell4OD and am
: having problems with handles.  Here is my code ...
: =====
: 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
:
: Public function Shell4OD( byVal cmd as string, byVal parameters as
: string, byVal Dir as string, byVal showHide as integer) As Boolean
:    Dim procHandle As Long, shellHnd As Long, taskID As Long
:
: ' hmmm  shellHnd = ???? <=== here is my problem
:
:         taskID = ShellExecute( shellHnd, _
:              vbNull,  cmd,  parameters, Dir, showHide)
:         ' get the process handle
:         procHandle = OpenProcess(&H100000, True, taskID)
:         Shell4OD = WaitForProcess( procHandle)
:         ' close the handle
:         CloseHandle procHandle
: end function
:
: ' Wait for a number of milliseconds, and return the running status
: ' of a process.  If argument is omitted, wait untill the process
: '  terminates.
: Function WaitForProcess(taskId As Long, Optional msecs As Long = -1) _
:     As Boolean
:         Dim procHandle As Long
:         ' get the process handle
:         procHandle = OpenProcess(&H100000, True, taskId)
:         ' check for its signaled status, return to caller
:         WaitForProcess = WaitForSingleObject(procHandle, msecs) <> -1
:         ' close the handle
:         CloseHandle procHandle
: End Function
: ====== end of code ====
: 


0
10/8/2003 2:09:25 AM
Reply:

Similar Artilces:

GUI: get handles from figure handle
a question from a newbie in GUI design... how to get the handles structure from the figure handle? thanks a lot! I just figureed it out from Matlab help. use guidata(hFigure) w. chen wrote: > > > a question from a newbie in GUI design... > > how to get the handles structure from the figure handle? > thanks a lot! type get(figure_handle) w. chen wrote: > > > a question from a newbie in GUI design... > > how to get the handles structure from the figure handle? > thanks a lot! ...

handles and GUIDE
Hii guys, I'm trying to learn more about handles in MATLAB because I'm creating a graphic interface using GUIDE and its essential to know how to use handles. I have a lot of situations where I need to use a value that is provided by a previous function, for example: My first pushbottom provide an value to an editable text object, when you write the number 2 in this place, I have a variable called number that assigns this value; In another part of my program, I am using a list of option object and when I select the first item of my list I want to my program print that numb...

process handle or PID to window handle or thread handle
Hello, Just for background, my ultimate goal is to pass messages using PostMessage from a service to GUI applications running not only on the console but also in things like TerminalServices (or similar products such as citrix or PCAnywhere or whatever). My question relates to this, but if anyone knows a totally different approach that would be welcome too. I need to go from a process handle (or alternatively PID) to either a window handle or thread handle. I've done some extensive searching and everything I've found points to using either EnumWindows or FindWindow if you...

number handling capabilities for visual basic applications
i am thinking of writing several mathematics applications that may be freely downloaded from the internet by users. i was wondering what the number handling was like in visual basic. some of these applications ,more specifically a prime number searcher, and a gcd/lcm calculator, require very large integer handling and display. i have used other languages and their number handling limits mean that they start to round numbers off when they get to the sort of 1000 billion mark or something. i was very impressed by a java application i once used that was seemingly limitless in the size of inte...

How to get the handle of an inactive window that is topmost visually on screen ?
sometimes, in win98 (and xp too?), when you close a window, the window just underneath it will shown but was disabled ( greyed), you can't get it's handle with GetForegroundWindow(), then, how to get the handle of this window ? Timpany wrote: > sometimes, in win98 (and xp too?), when you close a window, > the window just underneath it will shown but was disabled ( greyed), > you can't get it's handle with GetForegroundWindow(), > then, how to get the handle of this window ? use GetTopWindow(NULL); -- 677265676F727940346E6575726F6E732E636F6D ...

can cobol handle the handle?
Hello everyone, when we use the cobol command 'open i-o indexed-file', is there a way that I can get or obtain the file handle from the cobol runtime system? I need to use some win32 api functions and I must provide the file handle on entry as a call parameter. I am using Net Express 3.1 with windows 2000. thanks a lot for your kind help, Kellie. "KELLIE FITTON" <KELLIEFITTON@YAHOO.COM> wrote in message news:41758a6b.0401050801.418ca226@posting.google.com... > when we use the cobol command 'open i-o indexed-file', is there a way > that I can get or obt...

GUI handles
Hi again, I am elaborating a GUI which will derive into three "subGUI's" and all interact amongst them. I already know how to passa handles of the main objects between GUIs but i do not know how to access the other handles inside each object in each individual GUI. What i am trying to say is that i would like to change a handle that is inside an object in GUI 1, for example, through a callback in GUI 2... Can someone tell me how to access these "subhandles", i.e, handles that i created not the handles to the GUI's objects? Thank you in advance Luis ...

Factories, handles, and handle wrappers
Let's say you have a factory which returns handles to objects that it allocates. You pass these handles to the factory whenever you want to use the object or destroy it. The factory's "OperateOnObject" class verifies that the handle is within its object collection, and then marshals the OperateOnObject call to the class's internal OperateOnObject method. All external operations on the object instance are required to pass through the Factory in order to guarantee that the object instance is still valid at the time of call. This leads to code roughly like this. ...

Can REALBasic Handle This Simple Visual Basic App? Nope.
REAL Software has been claiming to be a good alternative to Visual Basic for a long time now. But can you really port VB apps to RB? Not really. Most VB apps use a lot of ActiveX components, and while you can certainly add ActiveX controls to your RB app, it only *looks* like it will work. The actual reality is not so pretty. On MSDN, there is a sample app containing 6 lines of code: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusingchartcontrol.asp Can RB handle this trivial app? Nope. It won't even compile it. I have uploaded a zi...

How to get the handles?
I am having 2 GUIs and i want to use the objects in the two GUIs in each other.my Question is how to get the handles of gui2 in gui1.how to refer the object in gui2 from gui1? Answers will be appreciated Hi, a good start for you : <http://www.mathworks.com/support/tech-notes/1200/1205.html> J�r�me ...another Colleague from the Matlab website suggested me weeks ago.., to call one GUI from the other as a function. When you start one of the GUIs, has it called the second one as a function, which returns the required handles. Another method involves the function "findobj". ...

Re: Can REALBasic Handle This Simple Visual Basic App? Nope.
Lewis Gardner <lgardner@simplifiedtechnologies.com> wrote: >MSChart.ocx is not a very good example. I don't know about that. I'll bet there are a lot of VB apps that use it. >When I try to load it in VB6 I get a license error. I have Office >installed. Who knows... That is a side issue. >RB2006r1 reports a data type error when running in the IDE. MSChart.ocx >apparently uses variant for .ChartData and the datatype may not be >compatible with RB. I never have trusted variants anyway. Yes, of course there is a reason why it doesn't wor...

Re: Can REALBasic Handle This Simple Visual Basic App? Nope. #2
Lewis Gardner <lgardner@simplifiedtechnologies.com> wrote: >I have never seen it in use in a non-demo application during my 10+ >years of supporting networks and VB programming that used MSChart. Well, I doubt any one person has ever observed more than 1% of VB apps. Neither one of us has presented any hard data, however, since the MSChart ocx is distributed with MS Office, it has certainly been available to millions of VB programmers. >The fact it does not run on a XP machine with VB6 and Office installed >certainly makes me question the stability of the O...

Re: Can REALBasic Handle This Simple Visual Basic App? Nope. #3
>Lewis Gardner wrote: >This is because it uses variants to contain arrays. >RB does not support variant arrays. Yes, the RB Language Reference states: "A Variant is a special data type that can contain any type of data." However, VisualBasic variants can contain arrays, and RB variants cannot. This is a serious compatability problem for porting VB apps to RB. And I don't believe it takes rocket science to implement. All you have to do is make the variant able to point to an array. Matt Posted with NewzToolz. Free RAR, PAR, and yEnc decoders. Get you...

Re: Can REALBasic Handle This Simple Visual Basic App? Nope. #4
Matt Trivisonno <matt@putmylastnamehere.com> wrote: >Yes, the RB Language Reference states: "A Variant is a special data type that >can contain any type of data." However, VisualBasic variants can contain >arrays, and RB variants cannot. This is a serious compatability problem for >porting VB apps to RB. And I don't believe it takes rocket science to >implement. All you have to do is make the variant able to point to an array. I would also like to add that this is yet another way that RS did a half-assed job. Sure you can do simple things with...

Question about handling handles in functions in MATLAB
I've found various suggestions on this group (using functions like guidata, guihandles, setappdata, getappdata) but I can't get my head around exactly how to use them in my situation. Below I describe how I solved my problem and I'd just like to know if there's something more straightforward. I have a figure (with handle 'h_img') with two sets of sliders and labels (call their handles h_a_slider, h_a_label, h_b_slider, and h_b_label.) The movement of either slider requires updating both labels; say that the function update_img.m performs this task. The only solution...

Unable to handle the handles between function calls!!!
Greetings, My program contains a lot of functions and i have used GUIDE to design the interface. But i am unable to share some of the variables common to some functions. I have tried updating the variables to the handles structure but in vain. How do i proceed?? Thanks in advance.... Hi, Could you please send a snipet of the code you think is not working? Lemon lemon wrote: > > > Hi, > > Could you please send a snipet of the code you think is not > working? > > Lemon > > here it goes.... ------------------------------------------------------ function X...

signal handling and (structured) exception handling
I'm a little bit at loss, why the new C++ standard (C++0x) does not include something like Windows structured exception handling. I certainly prefer a C++ Exception to a signal, as the signal only gives you the choice to terminate the process or mess around with something as ugly as setjmp/longjmp. And such signals/exceptions can sometimes not be avoided, e.g. in case of the system runs out of disk space while writing into memory created by memory mapped io from a sparse file. Even in case of a null pointer access I would prefer to keep the application running to be able to terminate it c...

how to handle exceptions raised while handling exceptions
Ciao, this is a problem for which I never found a satisfying solution. I have code that may misbehave if an exception is raised while it is already handling an exception. Specifically, in an UNWIND-PROTECT syntax: the cleanup forms may not be evaluated if a second exception is raised while serving the first. Is there some acceptable general solution? I do not know how Common Lisp's UNWIND-PROTECT handles this (given that CL has restarts, which are somewhat like continuable exceptions, so there is some code that must run after an exception is ra...

Getting native handles
Hi list, The fact that my previous email went unanswered (enumerating all windows in the system in a platform independent way), I'm assuming that it is impossible using wxWindows. I'm left with doing it using the X functions, which is ok, in itself. I would rather, however, not duplicate opening the display and creating a window so I can get the root window etc. Is it possible to get the Display and Windows handles of an open wxWindow, so I can manipulate it myself? I realize full well that all warranty is void once I do anything like that. Shachar ...

Getting a hConsoleOutput handle
Is there any way of getting a handle to the console of a Command Prompt application? I can get the process ID, because my Windows program ran the process in the first place, and I have the window handle. I want to read its buffer contents directly, rather than stuffing Alt-Space,e,s,Enter into the keyboard buffer and then reading the clipboard. Phil Hibbs. Phil Hibbs wrote: > I want to read its [another program's console] buffer contents > directly, rather than stuffing Alt-Space,e,s,Enter into the > keyboard buffer and then reading the clipboard. For the record, t...

Getting a hConsoleOutput handle
Is there any way of getting a handle to the console of a Command Prompt application? I can get the process ID, because my Windows program ran the process in the first place, and I have the window handle. I want to read its buffer contents directly, rather than stuffing Alt-Space,e,s,Enter into the keyboard buffer and then reading the clipboard. Phil Hibbs. Phil Hibbs wrote: > I want to read its [another program's console] buffer contents > directly, rather than stuffing Alt-Space,e,s,Enter into the > keyboard buffer and then reading the clipboard. For the record, t...

Getting a Handle on URNs
It is extraordinary how in just over a decade Uniform Resource Locators (URLs) have entered everyday life to such an extent that they are now found practically everywhere -- from the side of buses to the back of cornflake packets. But this universality tends to mask the fact that they suffer from a serious defect. Everyone has encountered the problem, which manifests itself as the dreaded "404 page not found" message. The trouble is that changes in site design, file directories and domain names can easily make a URL obsolete, with no means of automatically redirecting to the new Internet location (where it exists). What is needed is a standard way of permanently naming a digital resource similar to that provided by the International Standard Book Number (ISBN) for analogue books. The solution is to move from URLs to URNs: Uniform Resource Names. The important thing about URNs is that they do not point directly to an Internet resource, but are rather a placeholder for the location and other metadata. This means that the URN does not need to change if the URL does: it is enough to update the redirection. URNs sound great in theory. Unfortunately, progress towards realising them has been slow. One attempt to address what is sometimes called linkrot is the use of PURLs: Persistent URLs. This employs redirection to solve the problem of changes in directory structure, but is basically an adaptation of the URL. More thoroughgoing in its attempt ...

Basic event handling
Can anybody tell me why this isnt working. I get two error both saying "cannot find symbol" I have denoted them witha comment import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * Write a description of class gridLayout here. * * @author (your name) * @version (a version number or a date) */ public class gridLayout extends JFrame implements ActionListener { private JPanel grid = new JPanel( new GridLayout(3, 3)); public void actionPerformed(ActionEvent event) { System.out.println("Item: " + event.getActionCammand()); ...

Can I get a handle to ...
I like the Java implementation of a splash screen on the file exchange: <http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5946&objectType=file#> I particularly lick (sic) the example image ;) ... The function displays an image for a user-defined period using the Java interface to Matlab. I particularly like it because you don't get the figure window title bar etc., making it especially suitable for application splash screens. As currently implemented, the function requires the user to define the period for which the image will be displayed. What I would...

Web resources about - Getting handle on Handles? - comp.lang.visual.basic

Handle - Wikipedia, the free encyclopedia
A handle is a part of, or attachment to, an object that can be moved or used by hand. The design of each type of handle involves substantial ...

Beta Release of Adobe Social App Allows Marketers to Handle Facebook, Twitter Campaigns
Adobe , a Facebook Strategic Preferred Marketing Developer , announced a series of mobile-related additions to its Adobe Marketing Cloud , including ...

How-To: Handle Revoked Auth Permissions
This how-to document will help developers check a user's permissions and prompt that user for any missing permissions.

Facebook integration allows users of Freshdesk’s In-Sync app to handle customer service via the social ...
Cloud-based help-desk-software developer Freshdesk announced that its new In-Sync Facebook application is integrated with the social network, ...

16 Handles (@16Handles) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

You Can't Handle the Creative
In their 2011 study, "The Bias Against Creativity: Why People Desire But Reject Creative Ideas" by Jennifer Mueller (UPenn Wharton), Shimul Melwani ...

Handle: To-do List, Inbox, and Calendar Management all in one on the App Store
Read reviews, compare customer ratings, see screenshots, and learn more about Handle: To-do List, Inbox, and Calendar Management all in one. ...


Tesla Model S automatic door handle - YouTube
Interesting little element of the Telsa Model S show car, it has electric door handles that pop out after being touched and return flush to the ...

This could be the food of the future—if you can handle it
This is the same feeling all those Blue Apron customers get, right? (credit: Jason Plautz) The boxes at my door were plastered with red drawings ...

Resources last updated: 3/9/2016 11:32:54 PM