|
-
Mar 29th, 2000, 06:21 AM
#1
I want to double click on a file(lets say a *.txt file) and get it to launch my program(lets say a text editor that has a rich text box to load a file into) and have it load the file right into the rich text box with out the user doing anything other than double clicking the original file?
thanks yall
-
Mar 29th, 2000, 01:24 PM
#2
Lively Member
Why don't you write your app' so that it takes the file name as a commandline arguement.
then simply associate the file type u want with your application, using the standard windows method?
Or am i missing something??? 
Cheers
[email protected]
" Programming today is a race between software-engineers striving to build bigger and
better idiot-proof programs and the universe trying to produce bigger and better idiots.
So far the universe is winning". :-)
-
Mar 29th, 2000, 07:28 PM
#3
transcendental analytic
This function will return all command parameters in a variant that contains an array:
Function GetCommandLine(Optional MaxArgs)
'Declare variables.
Dim C, CmdLine, CmdLnLen, InArg, i, NumArgs
'See if MaxArgs was provided.
If IsMissing(MaxArgs) Then MaxArgs = 10
'Make array of the correct size.
ReDim argarray(MaxArgs)
NumArgs = 0: InArg = False
'Get command line arguments.
CmdLine = Command()
CmdLnLen = Len(CmdLine)
'Go thru command line one character
'at a time.
For i = 1 To CmdLnLen
C = Mid(CmdLine, i, 1)
'Test for space or tab.
If (C <> " " And C <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not InArg Then
'New argument begins.
'Test for too many arguments.
If NumArgs = MaxArgs Then Exit For
NumArgs = NumArgs + 1
InArg = True
End If
'Concatenate character to current argument.
argarray(NumArgs) = argarray(NumArgs) & C
Else
'Found a space or tab.
'Set InArg flag to False.
InArg = False
End If
Next i
'Resize array just enough to hold arguments.
ReDim Preserve argarray(NumArgs)
'Return Array in Function name.
GetCommandLine = argarray()
End Function
-
Mar 29th, 2000, 07:46 PM
#4
"Why don't you write your app' so that it takes the file name as a commandline arguement."
that exactly what i would like to do, but im not sure how to do it and what i need to do.
-
Mar 29th, 2000, 08:04 PM
#5
transcendental analytic
Copy the function in my last post and put this in your form_load event:
For Each n In GetCommandLine
If Not IsEmpty(n) Then Loadfile n: Exit For
Next n
And if you're making an MDI app, remove the Exit for. Rename Loadfile method, for whatever your method is to load the file.
Hope you get things work now!
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
|