想写一个枚举硬盘分区的dll

来源:互联网 发布:linux登录界面循环 编辑:程序博客网 时间:2024/05/22 07:53
我想写一个枚举硬盘分区的dll,代码如下enumpartition.h
#ifndef _ENUMPARTITION_H_
#define _ENUMPARTITION_H_
#define DLLIMPORT __declspec (dllexport)
typedef struct _EtParition
{
CHAR *path;
} EtPartition;
EtPartition et_pis[20];
ULONG et_np=0;
DLLIMPORT ULONG et_init();
DLLIMPORT CHAR* et_path(ULONG i);
DLLIMPORT UCHAR et_type(ULONG i);
DLLIMPORT LONGLONG et_size(ULONG i);
#endif

enumpartition.c
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <windows.h>
#include <initguid.h> // Guid definition
#include <devguid.h> // Device guids
#include <setupapi.h> // for SetupDiXxx functions.
#include <cfgmgr32.h> // for SetupDiXxx functions.
#include <devioctl.h>
#include <ntdddisk.h>
#include <ntddscsi.h>
#include <enumpartition.h>

BOOL APIENTRY DllMain(HINSTANCE hInstance,
DWORD reason,
{
return TRUE;
}
BOOL GetDeviceProperty(HDEVINFO IntDevInfo, DWORD Index )
{
SP_DEVICE_INTERFACE_DATA interfaceData;
}
DLLIMPORT ULONG et_init()
{
HDEVINFO hDevInfo, hIntDevInfo;
}
DLLIMPORT CHAR* et_path(ULONG i)
{
if(i>=et_np)return NULL;
}
DLLIMPORT UCHAR et_type(ULONG i)
{
if(i>=et_np)return NULL;
}
DLLIMPORT LONGLONG et_size(ULONG i)
{
if(i>=et_np)return NULL;
}

sources
TARGETNAME=enumpartition
TARGETTYPE=DYNLINK
TARGETPATH=obj
TARGETLIBS=$(DDK_LIB_PATH)/setupapi.lib
INCLUDES=$(BASEDIR)/inc;
SOURCES=enumpartition.c

我在ddk的build环境下用build编译,却出现如下错误BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.BUILD: Object root set to: ==> objchk_wxp_x86BUILD: Compile and Link for i386BUILD: Loading C:/WINDDK/3790/build.dat...BUILD: Computing Include file dependencies:BUILD: Examining d:/enumpartition directory for files to compile.    d:/enumpartition - 1 source files (166 lines)BUILD: Compiling d:/enumpartition directoryCompiling - enumpartition.c for i386NMAKE :  U1073: don't know how to make 'enumpartition.def'BUILD: nmake.exe failed - rc = 2BUILD: Compile errors: not linking d:/enumpartition directoryBUILD: Done    2 files compiled - 2 Warnings - 1 Error -   166 LPS
原创粉丝点击