|
-
Aug 5th, 2000, 11:08 AM
#1
Thread Starter
Lively Member
I asked it already yesterday but it won't work so I ask it again:
I want to associate my program with a specific file format. When someone clicks the file I would like to have my program opened and the file loaded. So I need to know the filename of the clicked file to load it with my program. Can somebody help me please by sending a clear explanation or an example project??
Thanx
-
Aug 5th, 2000, 11:16 AM
#2
-
Aug 5th, 2000, 11:25 AM
#3
Thread Starter
Lively Member
I tried this code already but this stuf doesn't work in VB6 enterprise. And I register my extension with a .reg file so that isn't the problem. The problem is how can I get the filename of the clicked file with my program?
-
Aug 5th, 2000, 11:53 AM
#4
That's passed through the Command line argument. The command line argument is represented by Command in VB. I.e If you made a Text Editor, you can use the following code to open the file that was clicked on.
Code:
Private Sub Form_Load()
Open Command For Input As #1
Text1.Text = Input(LOF(1), 1)
Close #1
End Sub
-
Aug 5th, 2000, 05:54 PM
#5
transcendental analytic
This one will allow several files to be opened with your app, storing file contents in yourarray
Code:
Dim X as integer, File as variant, Yourarray() as string
For each File In split(command$," ")
Open File For Input As #1
Redim Preserve Yourarray(X)
Yourarray(X)=Input(Lof(1),1)
X=X+1
Close #1
Next File
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 6th, 2000, 07:21 AM
#6
Thread Starter
Lively Member
When i try this code
Open command For Input As #1
Text1.Text = Input(LOF(1), 1)
Close #1
I get this error message:
Run-time error '75'
Path/file acces error
What am I doing wrong?
-
Aug 6th, 2000, 08:18 AM
#7
Monday Morning Lunatic
When the file association is registered, make sure that the %1 is in quotes:
Code:
c:\myprog\myprog.exe "%1"
Then you can split long filenames up properly.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 6th, 2000, 10:09 AM
#8
moperke:
I had that same problem,
i wanted to see why it wasnt working, so before I had the open code, I popped up a message box that told me what the "Command$" was,
it turns out there are quotes around the file name
so I did this
Code:
Dim FF As Integer
Dim FName As String
FF = FreeFile
FName = Replace(Command$, Chr$(34), " ")
FName = Trim$(FName)
Open FName For Input As FF
Text1 = Input(LOF(FF), FF)
Close FF
also, one more question,
how do I get the correct icon??
I can open files in my app, etc etc, but how do I get the icon?
I tried setting the default icon with the path to my exe and ",1" and I even tried using the ICO File....
I used the tip megatron posted the link to..
Thanks,
Dennis Wrenn
-
Aug 6th, 2000, 10:38 AM
#9
Thread Starter
Lively Member
thanx everyone who helped me, it works!
...
but I have a new problem: when my exe is located in a folder which contain spaces (like c:\Program Files\MyFolder\MyApp.exe) the command gives a DOS path like H:\DATA\MYFILE~1.EXT and I get a File not found error. How can I fix this problem?
-
Aug 6th, 2000, 10:50 AM
#10
Thread Starter
Lively Member
To change the icon you have to edit the 'DefaultIcon' in the registry. It's located in the same dir as 'Shell'.
-
Aug 7th, 2000, 03:50 PM
#11
I know that, I just cant seem to get the correct Icon, I have tried setting the default icon for a real icon, and for the exe's icon.....
please somebody help...
-
Aug 7th, 2000, 03:54 PM
#12
Monday Morning Lunatic
For an icon file, just reference it c:\myicon.ico
For an exe or dll, use c:\mydll.dll,4 where 4 is replaced by the index of the icon in the file.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 7th, 2000, 04:23 PM
#13
I tried that, it doesnt work.
-
Aug 7th, 2000, 04:38 PM
#14
Monday Morning Lunatic
Where are you putting it?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 7th, 2000, 06:21 PM
#15
HKEY_CLASSES_ROOT\ViewNFO\DefaultIcon
this is the path
C:\PROGRAM FILES\VIEWNFO\viewNFO.exe,1
-
Aug 8th, 2000, 03:29 AM
#16
Thread Starter
Lively Member
Another question
My program opens the files correctly but when I click a second file my program loads also a second time. What I want to do is open the second file with the same program as the first.
Any suggestions?
-
Aug 8th, 2000, 05:45 AM
#17
Monday Morning Lunatic
Use DDE. That's mainly what it's there for.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|