📄 selfextract.h
字号:
#ifndef ATTACH_H_INCLUDED
#define ATTACH_H_INCLUDED
/*
SelfExtract Class - attaching/detaching file to an executable.
Written by Nir Dremer
*/
// Using project must be linked with Shlwapi.lib in order to support PathFileExists.
#include <windows.h>
namespace GenLib
{
// Signature in the end of the file to verify attached file existance.
#define ATT_SIGSIZE 7
#define ATT_SIGNATURE "!faSig!"
class SelfExtract
{
public:
/*
Constructor, filename is the file you want to attach to or detach from.
*/
SelfExtract(const char *filename = 0);
~SelfExtract(void);
/*
SelfExtracting filename to the file given in the constructor.
Return value is 0 if finished successfully, or greater if failed.
*/
int attachFile(const char *filename, const char *writeName = 0);
/*
Detaching file to the given folder.
null/empty outFolder will result in detaching to current folder.
detachedFile is out parameter if you want to know the detached file filename.
detachedSize is the size of detachedFile.
Return value is 0 if finished successfully, or greater if failed.
*/
int detachFile(const char *writeFile, char *detachedFile = 0, int detachedSize = 0);
/*
Checking if _sourceFile holds attached file.
*/
bool checkSignature();
/*
Changing the filename given to constructor.
*/
void setFilename(const char *filename) { strcpy(_sourceFile, filename); }
/*
Get last filename of the detached file using detachFile method.
*/
char *getDetached() { return _lastDetached; }
private:
char _sourceFile[MAX_PATH];
char _lastDetached[MAX_PATH];
};
};
#endif // #define ATTACH_H_INCLUDED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -