Solved

programmatically running "assoc .pl=PERL"

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 42
ORA-01403: no data found 43 98
fizzArray2 challenge 1 78
Sed question 2 83
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 …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

813 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

12 Experts available now in Live!

Get 1:1 Help Now