Solved

programmatically running "assoc .pl=PERL"

Posted on 2000-05-04
5
240 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
  • 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 150 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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