File extension association
Hi quys.
I decompiled a cdlabel app 10 years ago and it works great. I can association the cdl extension no problem but when I double-click a cdl file it opens my app but it doesn't show the files data.
I've done a search on here for file association but there are no hints on how to get this to work. I've downloaded every app of PSC and they association the file but it still doesn't open.
I've added a Command$ for the file and it still doesn't show that file. Now Windows associates txt files to NotePad. I've checked every setting with txt files and they are exactly the same as my cdl but it still doesn't work.
Any tips would be gratefully recieved? ;)
If you want a link to this app on PSC then let me know.
Re: File extension association
Look at this example here http://www.vbforums.com/showthread.php?t=241188
I think the part you missed when associating is presented in this line with %1
Code:
AssociateMyApp "MyFileType", "C:\MyApp.exe %1", "xyz", , "C:\MyApp.exe,-1"
Which tells Windows to send the path of the file to the exe as a parameter, so you can pick it up with the Command function.
Re: File extension association
Thanks for the reply baja_yu.
I don 't think so baja_yu the %1 only associates the icon to the app which its already doing. It just won't open that file afterwards. ;)
Re: File extension association
Well... if double-clicking the file name starts your program then there is no problem with the association code at all. It's done it's job.
Your problem, most likely, is in parsing the datafile being passed. Are you parsing the file name passed for quotes and no quotes? Have you debugged the command$ open process?
Re: File extension association
Source code or it didn't happen. :lol:
Re: File extension association
Quote:
Originally Posted by
Keithuk
Thanks for the reply baja_yu.
I don 't think so baja_yu the %1 only associates the icon to the app which its already doing. It just won't open that file afterwards. ;)
erm... have you checked the parameter list?
Quote:
AssociateMyApp "MyFileType", "C:\MyApp.exe %1", "xyz", , "C:\MyApp.exe,-1"
Public Sub AssociateMyApp(ByVal sAppName As String, ByVal sEXE As String, ByVal sExt As String, Optional ByVal sCommand As String, Optional ByVal sIcon As String)
Re: File extension association
Thanks for your input guys.
Quote:
Originally Posted by
Tom Moran
Well... if double-clicking the file name starts your program then there is no problem with the association code at all. It's done it's job.
It is associated but it doesn't show that file.
Quote:
Originally Posted by
Tom Moran
Are you parsing the file name passed for quotes and no quotes? Have you debugged the command$ open process?
I've Run:
"C:\WINDOWS\CD Case Labeller.exe" "c:\Temp2.cdl"
and it opens CD Case Labeller.exe but it doesn't show Temp2.cdl.
I've checked the Command$ in Form_Load and just added Me.Caption = Command$. It just shows the normal title.
Quote:
Originally Posted by si_the_geek
erm... have you checked the parameter list?
Yes Si I've built a little app with that code and I've used
Code:
Private Sub Command1_Click()
AssociateMyApp "CD Case Label", "c:\windows\CD Case Labeller.exe %1", "cdl", "c:\windows\CD Case Labeller.exe,-1"
End Sub
And that makes no difference. ;)
Re: File extension association
I just tested the code that baja_yu linked to and it works fine for me on XP SP3.
Temp2.cdl has the icon of the executable. When double-clicking on Temp2.cdl, it starts the executable and the full path of Temp2.cdl can be retrieved from the Command$ function.
::edit::
Keithuk, you're using the wrong parameters.
Code:
AssociateMyApp "CD Case Label", "c:\windows\CD Case Labeller.exe %1", "cdl", "c:\windows\CD Case Labeller.exe,-1"
should be
Code:
AssociateMyApp "CD Case Label", "c:\windows\CD Case Labeller.exe %1", "cdl", , "c:\windows\CD Case Labeller.exe,-1"
Re: File extension association
Quote:
Originally Posted by
Chris001
I just tested the code that baja_yu linked to and it works fine for me on XP SP3.
Temp2.cdl has the icon of the executable. When double-clicking on Temp2.cdl, it starts the executable and the full path of Temp2.cdl can be retrieved from the Command$ function.
Code:
AssociateMyApp "CD Case Label", "c:\windows\CD Case Labeller.exe %1", "cdl", , "c:\windows\CD Case Labeller.exe,-1"
Yes my mistake there I copied and pasted the code wrong. I've changed it and it still doesn't work.
I don't know what you are associating Temp2.cdl with?
I put this in Form_Load to try and catch the Command$ but it just shows the normal Form Caption so there can't be any Command$.
Code:
If Command$ <> "" Then
Call LoadFile(Command$) 'Sub to load the file
Else
Me.Caption = Command$
End If
If you want the original app I posted on PSC 8 years ago then its CD Jewel Case Labeller
Its not a bad app really. I've changed a few things over the years but I haven't reposted it in there. ;)
Re: File extension association
Quote:
Originally Posted by
Keithuk
I put this in Form_Load to try and catch the Command$ but it just shows the normal Form Caption so there can't be any Command$.
Code:
If Command$ <> "" Then
Call LoadFile(Command$) 'Sub to load the file
Else
Me.Caption = Command$
End If
That code will only change the caption if Command$ is empty - which means that either the caption is blank, or you are getting something in Command$.
Based on that, I assume that LoadFile isn't working with it properly.
This is the kind of test code you should use instead:
Code:
Me.Caption = Command$
If Command$ <> "" Then
Call LoadFile(Command$) 'Sub to load the file
End If
Re: File extension association
Quote:
Originally Posted by
si_the_geek
That code will only change the caption if Command$ is empty - which means that either the caption is blank, or you are getting something in Command$.
Based on that, I assume that LoadFile isn't working with it properly.
This is the kind of test code you should use instead:
Code:
Me.Caption = Command$
If Command$ <> "" Then
Call LoadFile(Command$) 'Sub to load the file
End If
Yes Si I'm trying to check the Command$ or what ever but no Command$ is being sent to it.
Code:
If Command$ <> "" Then
Call LoadFile(Command$)
Else
Me.Caption = Command$
End If
If the Command$ is blank then it should show a blank Caption, it just shows the default Caption. Its not easy trying to send a Command$ to the app because you can't see what is happening.
I've added your Me.Caption = Command$ and it still only shows the default Caption.
The LoadFile sub is working properly as I can make out. Its the same code I use the Open file I just copied and pasted it into a Sub I'm supplying the filename with the Command$.
As I've said I've checked all the settings for a txt file with NotePad and they are exactly the same as mine. If you double-click a txt file that file opens in NotePad. ;)
Re: File extension association
This is the CD Labeler program from pscode and I've added the file association code that baja_yu linked to.
1) Compile the app.
2) Start the app and go to Options -> Associate with CDL extension.
3) Close the app.
4) Double-click on the Label.cdl file.
It should open the app and show a messagebox with the short and long path of the Label.cdl file.
<project removed>
Re: File extension association
Quote:
Originally Posted by
Keithuk
I've added your Me.Caption = Command$ and it still only shows the default Caption.
In that case either Command$ is exactly the same as the default Caption (which is extremely doubtful), or the Command$ code is not being run, or you are running other code which resets the caption and thus making other code which changes the caption irrelevant.
Re: File extension association
To be positive what is passed, do: MsgBox Command$, at the very begining of Form Load event.
Re: File extension association
Quote:
I don 't think so baja_yu the %1 only associates the icon to the app which its already doing. It just won't open that file afterwards.
i don't know if you fixed this yet, but if you do not have the %1 no filename will be passed to the command string, it will just open your program without command stirng
the icon is the -1 passed with the last argument
also if you drag files over your exe, any path/filename that contains spaces will, in the command string, be enclosed in quotes and must be treated accordingly
Quote:
C:\temp\mytest.csv C:\temp\new.htaccess "C:\temp\no pics.doc" C:\temp\index.htm
Re: File extension association
Quote:
Originally Posted by
baja_yu
To be positive what is passed, do: MsgBox Command$, at the very begining of Form Load event.
Ok I've tried MsgBox Command$ in Form Load and it shows the Command$. I've put the same MsgBox in the LoadFile Sub and it shows the same filename.
I've copied and pasted the same code from Open. I don't know why it doesn't show the file details. Once it opens you can click on Open that same file and it opens as it should do. ;)
Thanks westconn1 I've dragged the file over the exe and the MsgBox shows correctly but it doesn't show the details.
Re: File extension association
Thanks Chris001 it shows the long and short filenames in the MsgBox but it still doesn't open that files data. The association code is the same that I'm using. ;)
1 Attachment(s)
Re: File extension association
Sorry, but I didn't add the code to open the CDL file, just the messagebox.
Below is a new example. I've added a OpenFromCommand sub to load the data from the CDL file.
Re: File extension association
Sorry for not replying earlier Chris I had malware problem which I couldn't resolve so I did a format and rebuild last night.
No the problem is still there with your modded project2, if fact there is no difference between project1 and project2 Chris. ;)
Re: File extension association
Sorry, then I have no idea what's wrong. It works fine for me.
This is what I get when I start the executable normally.
http://i45.tinypic.com/2hx0e0.png
This is what I get when I double-click on the Label.cdl file.
http://i47.tinypic.com/k37ksj.png
Re: File extension association
Yes I've no idea whats stopping mine if yours works its got me baffled and I'm using WinXP SP3 just the same as you.
Thanks for trying Chris. ;)
Re: File extension association
have you put breakpoint in openfromcommand ans stepped through?
are you sure the input functions are returning what you expect, from the file