Including a Windows DDK Header

北慕城南 提交于 2019-12-12 05:46:34

问题


I am writing 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.


回答1:


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




回答2:


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.




回答3:


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


来源:https://stackoverflow.com/questions/3735087/including-a-windows-ddk-header

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!