包括一个Windows DDK标题 [英] Including a Windows DDK Header

查看:120
本文介绍了包括一个Windows DDK标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个用户空间的Win32应用程序。但是,作为这个应用程序的一部分,我需要对Windows 1394堆栈进行一些 DeviceIo 调用。包含这些 DeviceIo 调用原型的头文件作为Windows DDK的一部分包含在:

  C:\WinDDK\7600.16385.1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ b 

(虽然头文件声称是仅限于内核模式,但原型是针对用户空间IOCTL的。)我想知道在我的应用程序中包含此文件的最佳方式是什么。



直接执行 #include 的做法很差(路径取决于DDK版本等)除此之外,并不需要安装DDK ---我的应用程序对它的唯一依赖是用于这个非常头文件。



因此我想知道是什么最佳的行动方式是?我正在考虑直接在我的应用程序源代码中包含精简版的版本,但真的不确定。

比如说包括一个精简版本,或者如果你使用的东西真的很小,可以直接将它复制到项目的主头文件中。 不管你选择哪条路径,我都会说 c #define
这会导致正确的头部并导致麻烦。更好的办法是让用户定义到DDK的路径或者使用你的精简版本:

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

#if defined(__ WIN32_DDK_PATH)
#include STR(__ WIN32_DDK_PATH)
#else
//被剥离的DDK资料...
#endif

已测试上述使用gcc 3.4.5(旧的我知道,但dev-cpp是我所有的地方),工作正常


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.

解决方案

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

这篇关于包括一个Windows DDK标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆