64,685
社区成员
发帖
与我相关
我的任务
分享
//假设程序路径为C:\test\test.exe
//bin文件路径为C:\test\bin\test.bin
#include <stdio.h>
#include <string.h>
#include <windows.h>
......
unsigned char * Wrapper::ReadAFile(char *strName, int *piLen)
{
char filePath[MAX_PATH];
GetModuleFileName(0, filePath, MAX_PATH);
//此时filePath为:C:\test\test.exe
strcpy(strrchr(filePath, '\\') + 1, "bin\\test.bin");
//用strrchr找到最后一个 \ 的位置,然后用strcpy在其后面拼接bin文件路径
FILE pF =fopen(filePath, "rb");
......
}