//分区表解析动态链接库
//sptt.h文件
#ifdef SEARCHPARTITION
#else
#define SEARCHPARTITION extern "C" _declspec(dllimport)
#endif
#include <vector>
typedef struct _PARTINFO_
{
int fstype;
unsigned long int u64StartSector;
unsigned long int u64PartitonSizeOfSector;
}PARTINFO,*PPARTINFO;
SEARCHPARTITION int _stdcall SearchPartition(char *devicename,
unsigned long int startsector,
std::vector<PARTINFO> *partinfo);
//sptt.cpp文件
#define SEARCHPARTITION extern "C" _declspec(dllexport)
#include "sptt.h"
int _stdcall SearchPartition(char *devicename,
unsigned long int startsector,
std::vector<PARTINFO> *partinfo)
{
return 0;
}
不知道是否是使用了_stdcall 的缘故,或者是使用了extern "C",在使用vector容器定义变量的时候,必须使用std::为前缀!
以上的问题已经弄明白,原因在于命名空间的引用上,在vc.net中正确的vector使用应该为:
1在stdafx.h中加入 #include <vector>
2在命名空间中加入 using namespace std;
本文介绍了一个用于解析硬盘分区信息的动态链接库实现方法。该方法通过定义PARTINFO结构体来存储分区类型、起始扇区及大小等信息,并通过SearchPartition函数对外提供分区搜索功能。文章特别指出在导出和导入函数时使用_stdcall调用约定以及extern C关键字的原因,并强调了在使用vector容器时需明确指定std命名空间。
146

被折叠的 条评论
为什么被折叠?



