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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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?
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?
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)
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.
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.
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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"
Last edited by Chris001; May 23rd, 2010 at 03:33 PM.
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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.
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
Last edited by westconn1; May 24th, 2010 at 04:58 PM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
have you put breakpoint in openfromcommand ans stepped through?
are you sure the input functions are returning what you expect, from the file
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete