?
Solved

programmatically running "assoc .pl=PERL"

Posted on 2000-05-04
5
Medium Priority
?
247 Views
Last Modified: 2013-11-20
Using win32 commands, I'm able to mimic some Windows NT commands in my C++ program.

For example say that I ran "net user HenryVIII /add ..." at the command line. I would be able to achieve the same results in my C++ program by using the function NetUserAdd.

So my question is: Is there a win32 command that I can use to achieve the same result as typing "assoc .pl=PERL"?
0
Comment
Question by:mjswart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 2778537
Hi mjswart,

maybe of some help an sample from the MS site

http://support.microsoft.com/support/kb/articles/Q198/5/38.ASP

the code contains the functions to associate or disassociate a file with extension(s)

HTH:O)Bruintje
0
 
LVL 1

Expert Comment

by:cbeattie
ID: 2778597
You can emulate any dos command by using the system function.  All you have to include is stdlib.h.  The code below will do exactely what you want.

#include <stdlib.h>

int main(int argc, char* argv[])
{
   system("assoc .pl=PERL");
   return 0;
}
0
 
LVL 1

Author Comment

by:mjswart
ID: 2778631
Yeah, I've already thought of that.
But that command pops up a window very very briefly.
the flickering windows are quite annoying and if I wasn't concerned about style, I would accept it.

I've come up with

ShellExecute(NULL, NULL, "cmd.exe", "/C assoc .pl=PERL", NULL, SW_HIDE);

Can anyone think of anything better?
0
 
LVL 1

Accepted Solution

by:
cbeattie earned 300 total points
ID: 2778660
Nope, that would be my next suggestion.
0
 
LVL 1

Author Comment

by:mjswart
ID: 2780568
fair enough ;)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question