现在的位置: 首页 > 综合 > 正文

prjCDDoorControl(光驱门控制) – Win32 Application – VC++6 – HackerJLY

2013年12月07日 ⁄ 综合 ⁄ 共 2690字 ⁄ 字号 评论关闭

prjCDDoorControl(光驱门控制) - Win32 Application - VC++6 - HackerJLY

Main.cpp

//prjCDDoorControl - Win32 Application
/*====================================================================================================
VC环境中Link时默认引入的:(Project->Setting->Link->Object/Library Module)
 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
其中:没有 Winmm.lib
而:MSDN中注释中写到:要引入库:Winmm.lib,如下:
 QuickInfo
   Windows NT: Requires version 3.1 or later.
   Windows: Requires Windows 95 or later.
   Windows CE: Unsupported.
   Header: Declared in mmsystem.h.
   Import Library: Use winmm.lib. //要引入库:Winmm.lib
   Unicode: Implemented as Unicode and ANSI versions on Windows NT.
所以:编译时会报错:
  Main.obj : error LNK2001: unresolved external symbol
__imp__mciSendStringA@16
  Debug/prjCDDoorControl.exe : fatal error LNK1120: 1 unresolved externals
  Error executing link.exe.
  Creating browse info file...

  prjCDDoorControl.exe - 2 error(s), 0 warning(s)
解决方法:
1、在:Project->Setting->Link->Object/Library Module 中加入:Winmm.lib
2、在程序头部加上:#pragma comment(lib,"Winmm.lib")
-----------------------------------------------------------------------------------------------------
#pragma comment(lib,"Winmm.lib")
原形:
 #pragma comment( comment-type [, commentstring] )
当comment-type 为:lib 时:的意思是:
 Places a library-search record in the object file. This comment type must be accompanied by a
 commentstring parameter containing the name (and possibly the path) of the library that you want
 the linker to search. Since the library name precedes the default library-search records in the
 object file, the linker searches for this library just as if you had named it on the command line.
 You can place multiple library-search records in the same source file; each record appears in
 the object file in the same order in which it is encountered in the source file.
-----------------------------------------------------------------------------------------------------
另:
1、.lib : Win32下的静态库
 用VC新建项目时选WIN32   STATIC   LIBRARY就可以生成,它是:生成程序是要链接到程序内部的!
2、.dll : Win32下的动态库
 他是程序运行时,所动态加载的!
-----------
1、.h   :是类,函数,常量,类型,外部变量声明的地方,使用   #include   包含的原文件中。
2、.dll :是动态连接库,可以包含函数,类,控件的实现代码(已编译)
3、.lib :是静态连接库,或者是动态连接库的引入库,存放函数、类等的实现(静态连接库)或实现的 存根/代理(动态连接库的引入库)。
-----------
1、 .lib:导出函数的列表,他标示了到处函数在动态库中的位置,程序编译时使用。
2、 .h :是导出函数的申明。
3、 .dll:是导出函数所在的位置,运行时使用。

====================================================================================================*/
//#pragma comment(lib,"Winmm.lib")

#include <Windows.h>
#include <mmsystem.h>

int WINAPI WinMain(
  HINSTANCE hInstance,  // handle to current instance
  HINSTANCE hPrevInstance,  // handle to previous instance
  LPSTR lpCmdLine,      // pointer to command line
  int nCmdShow          // show state of window
)
{
 
 ::mciSendString("Set CDAudio Door Open Wait",NULL,NULL,NULL); //Open
 //::mciSendString("set cdaudio door closed wait",NULL,0,NULL); //Close
 return 0;
}
 

抱歉!评论已关闭.