Solved

Opening a file by mouse click

Posted on 2002-06-21
8
156 Views
Last Modified: 2010-05-02
hello
       How do I open any file by double clicking mouse button.
        Amitesh
0
Comment
Question by:ami12
8 Comments
 

Author Comment

by:ami12
ID: 7098116
Thanks
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 7098158
double clicking  Where ????


any how   U can Use Shell Command for exe

or ShellExecute API for any    dOCUMENT TO TRY TO RUN IT

hOPE THIS HELP
0
 
LVL 2

Accepted Solution

by:
priya_pbk earned 20 total points
ID: 7098384
By double clicking it, of course!! :0)

I think you might be wanting to do it programatically. is it?

Depends which file you wish to open by clicking what(ie command button or by filelistbox etc)

Try this:
Put a textbox, commondialog control and 2 command buttons on the form and copy this in the code window

------------------------------------------------
'decalare this first

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
               
Private Const SW_SHOW = 1


Private Sub Command1_Click()
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub


Private Sub Command2_Click()
Dim hBrowse As Long
hBrowse = ShellExecute(0&, "open", Text1.Text, "", "", SW_SHOW)
End Sub


Hope this helps!

-priya


0
 
LVL 6

Expert Comment

by:ebosscher
ID: 7098968
Do you mean how does the opeating system know which file to open when you double click on a file of a given type?  Do you want to know how to make windows run your program against a file of a given type when it's double clicked?

If so you would have to set the association of the extention with the file type in the registry

this happens fairly simply.

in HKEY_CLASSES_ROOT there is a high level node that is your file extention "i.e. .'.log'" the .log node tells the system where to look for more detailed info (a throwback to win 3.1 I guess)

so it looks like this

-[].log (Default)    REG_SZ    txtfile

in HKEY_CLASSES_ROOT there is another high level node that matches the Data paramater for the .log node (txtfile).  It contains the information on what to do with the file. It looks like this:

-[]txtfile (Default)    REG_SZ    file description
  |
  -[]DefaultIcon (Default)   REG_EXPAND_SZ    icon location
  |
  -[]Shell (Default)    REG_SZ    (value not set)
    |
    -[]open (Default)    REG_SZ    (value not set)
      |
      []command (Default)    REG_EXPAND_SZ    path to app  %1

NOTE: the %1 is the file the application will attempt to open, being passed as a command line parameter

NOTE2: I just reviewed my own registry, and this is how it LOOKS!!  if I'm wrong someone please correct me

I hope that helps.  Hopefully if you have some sort of installer for your application it should be able to set up this type of stuff for you, otherwise you might be looking at a little bit of work to get this running
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:ebosscher
ID: 7098979
crud, html makes my little chart thing look funny.. it looked a lot better when I typed it in the text box (should have used pre tags I guess)

Umm.. the []'s are supposed to denote a folder, or a node level, hopefully the indenting is obvious?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7099106
If you are talking about open a file with your app:
http://www.mvps.org/vbnet/code/reg/association.htm
0
 
LVL 6

Expert Comment

by:ebosscher
ID: 7099118
that basically describes what I outlined above?  except of course you give him the code... very nice.. I'll have to check that out sometime..
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7099278
No. It shows how to create an association for a given file (maybe  with a "custom" extension used only by your program). That's my idea. Sorry if i "override" your comment with something from it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now