473,387 Members | 1,318 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DOS Program to Change File Associations

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
13 3292

"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
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
"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
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
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
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
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
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
"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
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: The Roys | last post by:
I have a VB program which loads a jpg file into a picture box. I want to be able to d/click on the picture box and have Internet Explorer show this jpg file. What code do I put into the...
17
by: SK | last post by:
I am calling an exe thru' href, but when it executes, I get the message if I want to open the file(exe file). Is there any way I can suppress this from appearing and open the program? Thank...
1
by: Jason Gleason | last post by:
I wanted to know how you would associate a file extenstion with a c# program. For instance, I wanted to allow a user to double click a .org file, and then have it open in my org program (which is...
1
by: john | last post by:
I have an exe console app that i wrote, which works on custom data files. I'd like to give these data files a custom extension and somehow register that file extension with my exe, so all i have to...
3
by: Rupa | last post by:
Hi there, Does anyone know how we can PROGRAMMATICALLY change the program used to open a file? I am using vb.net. Any help will be gratly appreciated!! Thank you Rupa
2
by: Roger Miller | last post by:
When I installed Python 2.5 (on Windows XP) I left 2.4 in place "just in case". Today I decided to remove it. However after doing so (from the control panel) I found that Windows no longer knows...
0
by: Lyle Avery | last post by:
Hi guys, An uninstall of a previous version of Visual Studio, or anything (3rd party dev tools)else happen to unregister these (VS 2005) file extensions. I've tested the ¡°Restore File...
1
by: Lyle Avery | last post by:
Hi guys, Who knows how to restore VS 2k5 file associations, I've clicked Tools->General->"Restore File Associations" button but it doesn't work at all. I know Repair the whole product could fix...
3
by: luigi.amoroso | last post by:
Hi, Excuse for my English. I need to know which processes are attached to a file; for example if I open a txt file with notepad.exe, this process is attached to this file. Thanks a lot Luigi
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.