My Blog! blog.gkong.com   

Tip of my blog

新年快乐!


阅读(1218) 评论(0)
标签(TAG):

Note:
   Many CVI users who have no experience with direct SDK programming are surprised at first by the complexity of it. Support issues sometimes arise out of this, and it is important that we handle these issues appropriately. We do not want to be responsible for supporting Microsoft functions, but we do want CVI users to be successful with the product. This means that as a minimum you should know the issues involved with calling SDK functions from CVI(how to do it). Further knowledge of particular subsets of the SDK, knowing what the functions do and how they work, is not necessarily required but can be a tremendous asset to both you and the customer. Understanding how straight Windows application development is done will help you understand what goes on behind the scenes of CVI much more clearly.

(1) The SDK functions do NOT have function panels.
(2) #include <windows.h> //get the prototype or other definition
(3) Windows.h honors a set of macro definitions to control the subset of files included. For most cases, you can:
   #define WIN32_LEAN_AND_MEAN
Alternatively, you can set CVI up to define this for you(Compiler Definitions menu item). This will narrow the set of files included and increase compile time.Take a look in the header and you'll see the different definitions and which files they affect.

(important) You must include <windows.h> before the CVI Utility or Formatting and IO Library headers. These two libraries contain functions whose names are also defined in the SDK(CVI was there first). To avoid conflicts, include the CVI heders after the windows header, and the CVI headers will redefine the symbol to point to the CVI function names. There is information in the CAR database on manipulating these function names to use both the Windows and CVI versions.

As with any library, you must add SDK libraries to your CVI project in order to link the functions. Of special note is the fact that CVI will automatically try to link the three core SDK libraries regardless of whether you have them in your project. This is in effort to simplify the use of common SDK functions.
The three libraries that will link even without being included in the project are:  user32.lib  kernel32.lib  gdi32.lib

Win API 其实是个巨大的C 库,因为是较低层次的抽象,而CVI所自带的库是基于Win API更为高层的抽象,因此,能用CVI实现的不应用Win API。基于Win API的编程应作为最后的一板斧。

附录:

Calling a Windows SDK Function That Has the Same Name as a LabWindows/CVI Function

Missing Prototype Errors with Windows SDK and LabWindows/CVI

 如何在CVI中使用Windows SDK?

Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1()

Using the Windows SDK in CVI.pdf

///////////////////////////////////////////////////////////////////////////////
LabWindows/CVI中,所有的SDK函数都是以DLL的形式存在的。LabWindows/CVI与其外部编译器都包含了部分SDK函数的DLL引导库。大部分常用的SDK函数都包含在以下四个引导库中:

kernel32.lib
gdi32.lib
user32.lib
advapi.lib

LabWindows/CVI 在启动时会自动加载这四个库,并在链接时进行搜索以解析引用内容。因此,你不必将这些引导库加入工程文件。

如果 LabWindows/CVI 链接器报告SDK函数引用失败,你就必须将相关引导库加入工程文件。参考SDK具体函数的帮助,判断是否要将引导库加入工程文件。引导库文件都在cvi\sdk\lib目录下。

Interface to Win32 Application Programmatic Interface (API) Include Files

You must include the Interface to Win32 API include files before the LabWindows/CVI include files. This way, you avoid problems that arise from function name and typedef conflicts between the Win32 API and the LabWindows/CVI libraries. The LabWindows/CVI include files contain special macros and conditional compilation to adjust for declarations in the Win32 API include files. Thus, LabWindows/CVI must process the Win32 API include files first, followed by the LabWindows/CVI include files.

When you compile in LabWindows/CVI or when you use an external compiler to compile your source files for linking in LabWindows/CVI, use the LabWindows/CVI Win32 API include files. The LabWindows/CVI Win32 API include files are in the \sdk\include directory. The LabWindows/CVI compiler automatically searches the \sdk\include directory. You do not have to add it to your include paths.

When you use an external compiler to compile and link your source files, you must use the Win32 API include files that come with the external compiler. If you use an external compiler to compile your source files for linking in LabWindows/CVI, use the LabWindows/CVI Win32 API include files.

The number of Win32 API include files is very large. Normally, you must include only windows.h because it includes many, but not all, of the other include files. The inclusion of windows.h, along with its subsidiary include files, significantly increases compilation time and memory usage. WIN32_LEAN_AND_MEAN is a macro from Microsoft that speeds compiling by eliminating the less commonly used portions of windows.h and its subsidiary include files. By default, LabWindows/CVI adds /DWIN32_LEAN_AND_MEAN as a compile-time definition when you create a new project. You can alter this setting in the Compiler Defines section of the Build Options dialog box.

Note Note  The base version of LabWindows/CVI includes a subset of the Win32 API functions. To install the full set of Win32 API functions, you must select the Interface to Win32 API item in the NI LabWindows/CVI Full Development System installation. Refer to the Availability of Interface to Win32 API Functions topic for a full list of functions available in the Interface to Win32 API and the LabWindows/CVI version in which they are available.

Compiler Defines

The LabWindows/CVI compiler accepts compiler defines in the Build Options dialog box, which you can access by selecting Options»Build Options.

Compiler defines have the following syntax:

/Dx or /Dx=y

The variable x is a valid C identifier. You can use x in source code as a predefined macro. For example, you can use x as the argument to the #if or #ifdef preprocessor directive for conditional compilation. If y contains embedded blanks, you must surround it with double quotation marks.

The Predefined Macros dialog box, which you can access by selecting Predefined Macros in the Build Options dialog box, contains a list of the macros that LabWindows/CVI predefines. This list includes the name and value of each predefined macro.

Note  The default compiler defines string contains the following definition: /DWIN32_LEAN_AND_MEAN. This definition reduces the time and memory taken to compile include files for the Interface to Win32 API.

by 进化中的兔子 发表于:2010/8/7 8:53:40
My subject | 我的主题

New entries | 新发表

Messages Board | 留言板


Guest Comments | 新评注


Blogger Login | 登陆栏
Blog Infomation | 信息栏
博客名称:嵌入式系统&虚拟仪器 日志总数:450 评论数量:277 访问次数:1781245 建立时间::2005年10月25日
Blog Infomation | 搜索栏
Blog Infomation | 收藏栏

XML RSS 2.0

嵌入式系统&虚拟仪器
© COPYRIGHT 2004 ALL RIGHTS RESERVED http://www.gkong.com

中华工控网 | 联系我们 | 工控论坛首页 | 工控博客首页 | 博客注册 | 博客登陆

工控博客管理联系邮箱:工控博客服务邮箱

中华工控网 © Copyright 2013. All rights reserved.