?
Solved

programmatically running "assoc .pl=PERL"

Posted on 2000-05-04
5
Medium Priority
?
246 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

801 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