Solved

programmatically running "assoc .pl=PERL"

Posted on 2000-05-04
5
233 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 109
Expand macro to ask for filename column 8 35
WinWaitActive parameters 12 31
Detect file exist or not 3 80
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now