How do I include a file, then save the file to c:\windows

I need to update a .vxd file on many machines.
How can I take the updated file and include it in my c++ program, than run the program so that it copies and saves that file to C:\windows\system

Thanks for any help
Pat
poteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TriskelionCommented:
What do you mean by INCLUDE?
0
nietodCommented:
Your can write an "install" program that copies the file the the system directory using CopyFile().  

If the file you want to copy over is open by the system, it will fail.  In that case you can use MoveFileEx() to copy the file on an NT machine.  The documenation for MoveFileEx() explains how to achieve this on a windows 9x machine.
0
poteAuthor Commented:
By include I mean to distribute a new file, and have the exe rogram copy that file to the windows dir.
How do I reference the new file from within the C++ program, or where do I store the file, and how do I tell the program to copy the file to windows?


0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

nietodCommented:
Just store the new file somewhere on the instillation disk.  One common way to handle this is to just place the new file in the same directory as the installation program.  Then the instillation program can use GetModuleFileName() to get the path to itself, and then it can use this to get the path to the file to be installed.
0
cpopinCommented:
Are you trying to actually include the file in the EXE as data, then create the new VXD in the C:\Windows\System directory and and write out the data to the new file?  That way you can distribute one file.

If so, this is possible by converting the original VXD file to a CPP file in hex:

// NewVXD.CPP
unsigned char sVXD[] = {0xFE, 0xBE, ...};

Then create the file and write sVXD[] out to it.

You'd have to write (or find) a small utility program that converts the VXD to a CPP though.

Is this what you're asking for?
0
nietodCommented:
For that sort of approach you could just place the program to be installed inside the installation program as a binary resource.
0
KesslerCommented:
I am working with a similar situation that might clear up what pote is trying to do.  I would like to Import a binary file into the VS C++ 6.0 project Resource area so it is included in my executable.  Then, I would like to extract that file from the Resource area and save the file to a directory on the user's machine.  I don't know how to extract the file from the Resource area of the executable and save the file to the user's machine.  

pote, is this similare to what you are trying to accomplish?
0
cpopinCommented:
What I did was create a custom "EXECUTEABLE" type of resource named "TEST.EXE" and imported the file.  Then I used the following code to write it back out:

    const char sFileName[] = "TEST.EXE";
    HRSRC hrExe = FindResource(NULL, sFileName, "EXECUTEABLE");
    DWORD cExe = SizeofResource(NULL, hrExe);
    HGLOBAL hExe = LoadResource(NULL, hrExe);
    char *spExe = (char *)LockResource(hExe);
    CFile fExe;
    CFileException e;
    if (!fExe.Open(sFileName, CFile::modeCreate | CFile::modeWrite, &e)) {
#ifdef _DEBUG
        afxDump << "File could not be opened " << e.m_cause << "\n";
#endif
    }
    fExe.Write(spExe, cExe);
    fExe.Close();
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.