Link to home
Start Free TrialLog in
Avatar of zhangjing
zhangjing

asked on

How to link a file extension to my vb program?

I am making a vb program, I want after I install my vb program, when people double click on one kind of file extension, say ".abc", then it automatic active my program and execute that file. Is that possible?
Avatar of JonFish85
JonFish85

to get whatever parameters are passed to your application, in the form_load procedure go like this:

Private Sub Form_Load()
  MsgBox Command$
End Sub


Command$ is a variable that VB itself creates and fills or whatever. When the user doubleclicks a .abc file, your application will open, and the filename will be in Command$. You just have to check, when the form is loading, whether the user is starting a brand new instance, or just opening a .abc file by double clicking the file. There, how's that for making an easy procedure seem ahrd?
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zhangjing

ASKER

Well, I know I can use registery to do that. But think of one people first time install my program, and then he double click on .abc file, what will he get? He still can't make my program running, cause my program is not linked to .abc yet. So the only way to solve that is when they INSTALL my program, the install program already link it. That's most of other program did. I want to do things like that way, not by clicking a button or what else.
Then, i suggest compile the above codes to a program, then run it during the installation.
Hi zhangjing,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept JonFish85's comment(s) as an answer.

zhangjing, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
How this happened, zhangjing?! Do you accept my comments as the answer or JonFish85's? If you do accept my comments as answer, is me deserve a "C"?! Please give a reason here.
ryancys, you do not need to accept such an insult from zhangjing.  I suggest that you post to Community Support and have them remove this ugly mark from your grading history.  I am sorry that my cleanup efforts have lead to this.

-- Dan
Thanks Dan, yes i will post an request to change the grade at few days later, if zhangjing not give me a reasonable answer.

Thanks to clear up the comments in EE too, Dan. Your effort is appreciated.
Opps!

> Thanks to clear up the comments in EE too, Dan. Your effort is appreciated.

should be:

Thanks to clear up the questions in EE too, Dan. Your effort is appreciated.
ryancys,

Yes, I do accept your comment as answer, the program works, but it doesn't totally solve the problem, your last line is this: "Then, i suggest compile the above codes to a program, then run it during the installation", right? But that means I have to rewrite the VB install program, of course that's possible, but I don't mean that, why not I make a VB compiler by myself? The reason I post this question here is I want to find some really "Good" solution, not so difficult. Also, for DanRollins, I don't understand why he want me to accept JonFish85's answer, I checked both of your answers very carefully, I found your answer is more "near" the result, but still not "exactly" reach it. So when I give mark, A means Excellent, B means good, C means Average, so I think "C"-"Average" is ok, if the rule here think that "Average" is an "insult", then what is "Reject" mean? Please let DanRollins or which other moderator decide, if you all think that it worth B or A, then please help me to modify it to B or A, and say Sorry to ryancys, I don't want to "insult" anyone.
Also, please read my question again: "I want after I install my vb program, when people double click on one kind of file extension, say ".abc", then it automatic active my program and execute that file. Is that possible?" I know all the code that after first run your program, then have form, blah, blah, blah, that's not the point, I want it to associate IN the install program, not AFTER that, most of the program can do that, does Microsoft Office need you to first install it then run it to link .doc to Word? of course not, that's what I want to do. So, maybe if you directly told me: "No, that's impossible to do in VB." That seems truth, then I may give you a "B" or even "A", sometimes, "No" is excellent answer. Sorry.
zhangjing,
If you want excellent answers from the Experts here, you need to provide clearly-worded questions that express exactly what you need to know.  You then need to provide additional feedback so that the Experts know how to continue in helping you.  If you abandon questions and never respond to the expert comments, and if you then grade with a C without giving the expert a chance to provide a better answer, then the Experts will stop helping you in new questions.

>>I don't understand why he want me to accept JonFish85's answer

Before making my recommendation, I checked JonFish85's first link and it describes in perfect detail how to programmatically associate a file extension with a program.  That answers your original question EXACTLY.  

You then added a new request that it needed to be done BEFORE your program was ever executed.  JonFish85's answer was still exactly correct -- you just need to take the obvious step of doing it in your setup program.

ryancys comment was similar to the code that had already been provided by JonFish85's link.  

So, that is why I recommended JonFish85's comment as an answer.  Do you have any other questions?

-- Dan
Dan,

You told me to "finalize it within 7 days." So after compare all answers, I'd like to choose ryancys's comment as answer.

Please read my original question carefully: "I want after I install my vb program, when people double click on one kind of file extension, say ".abc", then it automatic active my program and execute that file. Is that possible?"

If I use JonFish85 and ryancys's answer and code it in, will it have the effect "after I install my vb program, when people double click on one kind of file extension, say ".abc", then it automatic active my program and execute that file"?

Everybody here can try that, it WON'T. So I grade it C, it means "Average" acceptable answer, but not "Bad" answer, right?
Yes, I have read your question many times now.  There is a subtle mistake in it that has confused the experts.  You said:

   >> ...after I install my vb program, when people double click on one...
but you should have said:
   >> ...DIRECTLY after I install my vb program, BEFORE ANYONE RUNS IT, when people double click on one...

If you had said that then everybody here would have helped you work toward the solution you wanted.  I'm sorry that it did not go well for you.  

>> So I grade it C, it means "Average" acceptable answer, but not "Bad" answer, right?

No.  C is almost never acceptable.  It can ruin an expert's grading history.  Please look at the grading guidelines here:

   https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3

You did not ask for clarification of ryancys's final comment so you have no cause to give a C.
 
-- Dan
Yes, you understand my original question. Thank you!

Also, I noticed there is a sentence in the grading guidelines just below "C": You also have the option here of just asking Community Support to delete the question.

I don't think ryancys's answer hit my question, so I can't grade his answer as A or B, so I ask to delete the question.

Sorry to ryancys and JonFish85, that's all I can do.
Ok, zhangjing. I accept your comments to explain why i deserve a 'C', i will not post a request on Community Support to change this question's grade. Just be kind next time to award other expert with better grades if you do post some other questions in EE. And what i can say is another 'C' grades in my PAQ question list. Hmmm, so bad sometimes. But as i accept your explaination it is ok.