开发者

Including a Windows DDK Header

I am writing 开发者_StackOverflow中文版a user-space Win32 application. However, as part of this application I need to make some DeviceIo calls to the Windows 1394 stack. The header file which contains the prototypes for these DeviceIo calls is included as part of the Windows DDK at:

C:\WinDDK\7600.16385.1\inc\api\ntdd1394.h

(Although the header claims to be "Kernel mode only" the prototypes are for user-space IOCTLs.) I am wondering what the best way to include this file in my application is.

It would be poor practice to #include it directly (the path depends, among other things, on the DDK version) and in addition there is no real need for the DDK to be installed --- the only dependency my application has on it is for this very header file.

Hence I am wondering what the best course of action is? I was considering including a stripped-down version of it directly in my applications source but really am not sure.


I'd say include either a stripped down version, or if what your using is really small, import copy it directly into the main header for your project.

regardless which path you take, I'd say wrap both in #define guards, incase someone else who tinkers with this inports the correct header and causes trouble. Even better would be something to allow the user to either define the path to the DDK or use your stripped down version:

#define EXP(x) #x
#define STR(x) EXP(x)

#if defined(__WIN32_DDK_PATH)
    #include STR(__WIN32_DDK_PATH)
#else
//Stripped DDK stuff...
#endif

tested the above using gcc 3.4.5(old I know, but dev-cpp is all I have where I am), works fine


How are you linking against the actual implementations of these functions? The documentation for the library you are linking against should tell you what to #include.

Also, do you need other people to be able to build this application or is it a one-man job? You could always set up a virtual build machine which has the DDK installed and #include the file that way.

Otherwise, yes, including the function prototypes in your own stripped down header file (with a comment to say why you are doing this!) is probably the way to go.


This works for me (taken from one of the samples in DDK):

#define _WIN1394_C
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <ntdd1394.h>
#undef _WIN1394_C
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜