By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,732 Members | 843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,732 IT Pros & Developers. It's quick & easy.

DOS Program to Change File Associations

P: n/a
I'm looking for the source code for a DOS command line c/c++ program
that can change file associations. In other words it can cause any
version of Windows to associate a particular .exe file with a
particular file name extension.

It would be preferable if the source code would work with Borland's
free DOS command line C/C++ compiler.

Oct 8 '06 #1
Share this Question
Share on Google+
13 Replies


P: n/a

"James Reid" <a8******@hotmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
I'm looking for the source code for a DOS command line c/c++ program
that can change file associations. In other words it can cause any
version of Windows to associate a particular .exe file with a
particular file name extension.

It would be preferable if the source code would work with Borland's
free DOS command line C/C++ compiler.
1) This is a system specific request this group only deals with questions
about "standard" C....

<Pedant Mode On>
2. As a DOS program cannot by definition know any thing about Windows System
calls what you ask is, strictly speaking impossible. You can build what I
think is called a "Command Window .exe", which looks a bit like a DOS
program to the casual user, but which is really a Windows program that runs
in a cmd window.....

Whats wrong with using the currently free "Visual Studtio Express"?

Dave.
Oct 8 '06 #2

P: n/a
David Wade wrote:
2. As a DOS program cannot by definition know any thing about Windows System
calls what you ask is, strictly speaking impossible.

You can build what I
think is called a "Command Window .exe", which looks a bit like a DOS
program to the casual user, but which is really a Windows program that runs
in a cmd window.....
Yes. That's probably what the "assoc" program is. "assoc" is a program
which comes with Windows XP. It's a command line program, and one of
the things that it does is to allow file associations to be changed.

But what I want is the source code for such a program so that I can
have it assign a specific file name extension with a specific program,
and so that it works with all versions of Windows.
Whats wrong with using the currently free "Visual Studtio Express"?
Oh. I didn't know about that. I'll check it out. Thanks, David.

James

Oct 8 '06 #3

P: n/a
"James Reid" <a8******@hotmail.comwrites:
David Wade wrote:
>2. As a DOS program cannot by definition know any thing about Windows System
calls what you ask is, strictly speaking impossible.

You can build what I
think is called a "Command Window .exe", which looks a bit like a DOS
program to the casual user, but which is really a Windows program that runs
in a cmd window.....

Yes. That's probably what the "assoc" program is. "assoc" is a program
which comes with Windows XP. It's a command line program, and one of
the things that it does is to allow file associations to be changed.

But what I want is the source code for such a program so that I can
have it assign a specific file name extension with a specific program,
and so that it works with all versions of Windows.
And you are asking in the wrong place. Standard C cannot do what
you're trying to do without system-specific extensions. Try a Windows
newsgroup.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 8 '06 #4

P: n/a
Keith Thompson wrote:
>
And you are asking in the wrong place. Standard C cannot do what
you're trying to do without system-specific extensions. Try a Windows
newsgroup.
Isn't it simply a matter of making changes to the registry? Any
programming language should be able to do that.

Oct 9 '06 #5

P: n/a
Keith Thompson wrote:
>
And you are asking in the wrong place. Standard C cannot do what
you're trying to do without system-specific extensions. Try a Windows
newsgroup.
Isn't it simply a matter of making changes to the registry? Any
programming language should be able to do that.

Oct 9 '06 #6

P: n/a
James Reid said:
Keith Thompson wrote:
>>
And you are asking in the wrong place. Standard C cannot do what
you're trying to do without system-specific extensions. Try a Windows
newsgroup.

Isn't it simply a matter of making changes to the registry? Any
programming language should be able to do that.
Show me. Show me how Fortran 77 can make changes to the registry. Or ISO
Basic. Or Algol-68. Are those languages too old for you? Okay, let's see
you do it in Ook!, or Whitespace, or Princess.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 9 '06 #7

P: n/a
Richard Heathfield wrote:
Show me. Show me how Fortran 77 can make changes to the registry. Or ISO
Basic. Or Algol-68. Are those languages too old for you? Okay, let's see
you do it in Ook!, or Whitespace, or Princess.
The Windows "Registry" means binary files. Even GWBASIC can change
binary files! What's the problem?

Oct 9 '06 #8

P: n/a
James Reid said:
Richard Heathfield wrote:
>Show me. Show me how Fortran 77 can make changes to the registry. Or ISO
Basic. Or Algol-68. Are those languages too old for you? Okay, let's see
you do it in Ook!, or Whitespace, or Princess.

The Windows "Registry" means binary files. Even GWBASIC can change
binary files! What's the problem?
Pretend I'm from Missouri. You gots to show me.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 9 '06 #9

P: n/a
"James Reid" <a8******@hotmail.comwrites:
Keith Thompson wrote:
>And you are asking in the wrong place. Standard C cannot do what
you're trying to do without system-specific extensions. Try a Windows
newsgroup.

Isn't it simply a matter of making changes to the registry? Any
programming language should be able to do that.
Standard C, which is what we discuss here, has absolutely no concept
of a "registry".

I'm sure it's possible to make changes to the registry using some
system-specific extensions. We don't discuss system-specific
extensions here.

Try a Windows newsgroup. You're likely to get an answer in
comp.os.ms-windows.programmer.win32. You're not likely to get an
answer in comp.lang.c (and if you do, nobody else here is going to be
able to find any bugs in it).

You've been told several times that this isn't the right place for
your question. Why don't you believe us?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 9 '06 #10

P: n/a
"James Reid" <a8******@hotmail.comwrites:
Richard Heathfield wrote:
>Show me. Show me how Fortran 77 can make changes to the registry. Or ISO
Basic. Or Algol-68. Are those languages too old for you? Okay, let's see
you do it in Ook!, or Whitespace, or Princess.

The Windows "Registry" means binary files. Even GWBASIC can change
binary files! What's the problem?
<OT>
Presumably the operating system provides an interface that deals with
the registry. Attempting to treat it as binary files sounds extremely
dangerous, and subject to random failure in different versions of the
operating system.

Use the OS-provided interface. Ask about it in a newsgroup where it's
topical.
</OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 9 '06 #11

P: n/a
On 9 Oct 2006 08:51:14 -0700, in comp.lang.c , "James Reid"
<a8******@hotmail.comwrote:
>Keith Thompson wrote:
>>
And you are asking in the wrong place. Standard C cannot do what
you're trying to do without system-specific extensions. Try a Windows
newsgroup.

Isn't it simply a matter of making changes to the registry?
What registry?
Any programming language should be able to do that.
Only using system specific extensions. Really, you need to ask in a
Windows newsgroup.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 9 '06 #12

P: n/a
On 9 Oct 2006 10:40:48 -0700, in comp.lang.c , "James Reid"
<a8******@hotmail.comwrote:
>Richard Heathfield wrote:
>Show me. Show me how Fortran 77 can make changes to the registry. Or ISO
Basic. Or Algol-68. Are those languages too old for you? Okay, let's see
you do it in Ook!, or Whitespace, or Princess.

The Windows "Registry" means binary files. Even GWBASIC can change
binary files! What's the problem?
Sure, you can change it with C. All you need to do is

a) discover the binary format of the registry
b) discover how to bypass security so you can see the bits you need
c) fopen the registry file (lets pretend its an ordinary file)
d) fseek to the right place, somehow
e) change some bits in it. Note that in-place file editing is in
general impossible in Standard C. And you can't use the usual trick of
copying the file to a new one since the file is locked open by the OS.
f) close the file and hope like hell you didn't fsck your registry.
g) reboot the PC and pray.
h) reinstall Windows and curse.

Or alternatively you could go to a windows group and ask how to use
the registry editing functions in the Win32 API.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 9 '06 #13

P: n/a
On 9 Oct 2006 08:52:43 -0700, in comp.lang.c , "James Reid"
<a8******@hotmail.comwrote:
>Keith Thompson wrote:
>>
And you are asking in the wrong place. Standard C cannot do what
you're trying to do without system-specific extensions. Try a Windows
newsgroup.

Isn't it simply a matter of making changes to the registry? Any
programming language should be able to do that.
Sure. However you need to make specific changes which have meaning and
don't toast the rest of the file.

Would you modify a database by opening it as a plain binary file, and
hacking around in it, or would you use the API designed specially to
access the data? Would you edit a sound file by opening it as plain
binary and flipping bits, or would you use a sound editing API?

And if you're asking "how do I write an API to modify the Windows
registry", you DEFINITELY need to go to a windows group.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 9 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.