-
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
-
-
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?
-
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
-
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
-
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?
-
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.
-
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
-
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?
-
To change the icon you have to edit the 'DefaultIcon' in the registry. It's located in the same dir as 'Shell'.
-
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...
-
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 tried that, it doesnt work.
-
Where are you putting it?
-
HKEY_CLASSES_ROOT\ViewNFO\DefaultIcon
this is the path
C:\PROGRAM FILES\VIEWNFO\viewNFO.exe,1
-
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?
-
Use DDE. That's mainly what it's there for.