如何将所有发布文件合并到一个.exe文件中? [英] How can I merge all release files into ONE .exe file?

查看:140
本文介绍了如何将所有发布文件合并到一个.exe文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我按顺序改进了我在项目中所做的事情。



告诉我从下面的句子中删除什么。



1)项目名称是FaceRecognition。



2)项目依赖于.xml,.dll,.jpg。



3).xml文件是:

1)haarcascade_frontalface_alt2.xml

2)haarcascade_mcs_lefteye.xml和另外三个文件。



4).dll文件是:

1)cv210.dll

2)cvaux210.dll和另外8个dll文件。



5).jpg文件是:

1)down.jpg

2)normal.jpg和另外4个jpg文件。



6)所有这些。*文件被添加到解决方案资源管理器中的preoject的资源文件中。



7)并且来到.rc文件这里我添加完整这些文件的路径如:



IDR_XML1文件C:\\FaceR ecognition\\FaceRecognition\\haarcascade_frontalface_alt2.xml

IDR_XML2 FILEC:\\FaceRecognition\\FaceRecognition\\haarcascade_mcs_lefteye.xml



.....

IDR_DLL1文件C:\\FaceRecognition\\FaceRecognition\\cv210.dll

IDR_DLL2文件C:\\FaceRecognition\\FaceRecognition\\cvaux210.dll



.... 。

IDR_JPG1文件C:\\FaceRecognition\\FaceRecognition\\down.jpg

IDR_JPG2文件C:\\FaceRecognition \\FaceRecognition\\\\
ormal.jpg



.....



8)并且在代码中我将这些.xml和.jpg分配给变量,我还给出了



的完整路径。



9)Last是createfilefromresource()函数,我应该在项目中编写这个函数,我应该将哪些参数传递给函数。



这是我正在项目中进行合并所有文件与.exe的过程。



从这个PLZ提到我正在做的事情以及我做错了什么。 />


非常感谢你。

Hello,

I improved my question in a sequence what i am doing in the project.

Just tell me what to be removed from below lines of sentences.

1) Project name is FaceRecognition.

2) Project is having dependency of .xml, .dll, .jpg.

3) .xml files are:
1) haarcascade_frontalface_alt2.xml
2) haarcascade_mcs_lefteye.xml and three more files.

4) .dll files are:
1)cv210.dll
2)cvaux210.dll and 8 more dll files.

5) .jpg files are:
1) down.jpg
2) normal.jpg and 4 more jpg files.

6) all these .* files are added to the resource files of the preoject in solution explorer.

7) and coming to .rc file here i am adding the complete path of these files like:

IDR_XML1 FILE C:\\FaceRecognition\\FaceRecognition\\haarcascade_frontalface_alt2.xml"
IDR_XML2 FILE "C:\\FaceRecognition\\FaceRecognition\\haarcascade_mcs_lefteye.xml"
.
.....
IDR_DLL1 FILE "C:\\FaceRecognition\\FaceRecognition\\cv210.dll"
IDR_DLL2 FILE "C:\\FaceRecognition\\FaceRecognition\\cvaux210.dll"
.
.....
IDR_JPG1 FILE "C:\\FaceRecognition\\FaceRecognition\\down.jpg"
IDR_JPG2 FILE "C:\\FaceRecognition\\FaceRecognition\\normal.jpg"
.
.....

8) and in the code i am assigning these .xml and .jpg to variables, there also i am giving

the full path.

9) the Last is createfilefromresource() function where should i write this function in the project and what parameters should i pass to the function.

this is the process i am doing in the project to merge all files with an .exe.

From this plz mention what i am doing right and what i am doing wrong.

Thank u very very much.

推荐答案

我在我的一些代码中这样做。



您可以将数据嵌入.exe文件的资源中。为此,在构建.exe时,所有要嵌入的文件都需要存在。将文件作为资源添加到封闭的.exe文件中(您询问的是C ++和MFC;该过程与.NET略有不同)。为此,将每个文件添加为.rc或.rc2文件中的行项,就像使用位图和图标一样:



I do this in some of my code.

You can embed the data into resources of the .exe file. To do this, all of the "to be embedded" files need to exist when the .exe is built. Add the files as resources to the enclosing .exe file (you asked about C++ and MFC; the process is a little different for .NET). To do this, add each file as a line item in the .rc or .rc2 file, just as you do with bitmaps and icons:

/////////////////////////////////////////////////////////////////////////////
//
// Icon

IDR_MAINFRAME           ICON                 "blahblah\\icons\\blahblah.ico"

/////////////////////////////////////////////////////////////////////////////
//
// HTML

IDR_FILE_RELEASENOTES   HTML                 "blahblah\\text\\blahblah_releasenotes.htm"

/////////////////////////////////////////////////////////////////////////////
//
// FILE

IDR_FILE_PARAM          FILE                 "blahblah\\paramdata\\PARAMS.XML"
IDR_FILE_TEST           FILE                 "blahblah\\paramdata\\TESTDATA.DAT"









这是我用来将数据提取到af的代码ile(当我的程序运行时):







Here is the code I use to extract the data to a file (when my program runs):

bool CreateFileFromResource(char const* sFilename, HMODULE hInstance, WORD resourceID)
{
    bool bRetval = false;
    HANDLE hFile = CreateFile(sFilename, GENERIC_READ | GENERIC_WRITE,
        0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    _ASSERTE(hFile);
    if(hFile)
    {
        _ASSERTE(hInstance);
        //if(NULL == hInstance)
        //    hInstance = AfxGetResourceHandle();

        HRSRC hResource = FindResource(hInstance, MAKEINTRESOURCE(resourceID), "FILE");
        _ASSERTE(hResource);
        if(hResource)
        {
            HGLOBAL hFileResource = LoadResource(hInstance, hResource);
            _ASSERTE(hFileResource);
            if(hFileResource)
            {
                LPVOID lpFile = LockResource(hFileResource);
                _ASSERTE(lpFile);
                if(lpFile)
                {
                    DWORD dwSize = SizeofResource(hInstance, hResource);

                    HANDLE hFilemap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwSize, NULL);
                    LPVOID lpBaseAddress = MapViewOfFile(hFilemap, FILE_MAP_WRITE, 0, 0, 0);

                    CopyMemory(lpBaseAddress, lpFile, dwSize);

                    UnmapViewOfFile(lpBaseAddress);
                    CloseHandle(hFilemap);
                    bRetval = true;
                }
            }
        }
        CloseHandle(hFile);
    }
    return bRetval;
}





我还有代码将嵌入资源(通常是xml)的内容提取到字符串或DOM中我肯定你可以从上面弄清楚。



如上所述,这段代码适用于原生C ++ / MFC环境(即如果你建立一个RES文件)。概念是相同的,但在.NET中具有不同的细节(即,如果您使用.RESX文件)。



I also have code to extract the contents of an embedded resource (usually xml) into a string or a DOM which I''m sure you can figure out from the above.

As I said above, this code works in a native C++/MFC environment (ie. if you build a RES file). The concept is the same but with different details in .NET (ie. if you use a .RESX file).


您可以使用WinZip或WinRar之类的东西创建压缩存档。但是,更好的选择是使用可用的工具之一创建程序安装程序; Google会为您找到一些建议。
You can create a compressed archive using something like WinZip or WinRar. However, a better choice would be to create a program installer using one of the tools available; Google will find you some suggestions.


这篇关于如何将所有发布文件合并到一个.exe文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆