问问题

qiyanchao 2004-04-29 09:14:54
vc中怎样使用API函数
直接用不行啊
比如这样,就会说你没有声明
void CWwwwDlg::OnButton1()
{
// TODO: Add your control notification handler code here
::mciExecute("open c:\aa.wma alias wma");
::mciExecute("play wma");

}

我在MSDN中查到这个函数要求的头文件如下
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Mmsystem.h; include Windows.h.
Library: Use Winmm.lib.
我加进去了,还是不行啊
我在StdAfx.h中加入
#include <Windows.h>
#include <Mmsystem.h>
又把Winmm.lib考到VC文件的根目录下和DEBUG目录下
然后在link选项中加入Debug\Winmm.lib
还是不行

...全文
15 3 点赞 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
qiyanchao 2004-04-29
我就不信这么简单的问题会没有人解决
再顶
  • 打赏
  • 举报
回复
qiyanchao 2004-04-29
我是在VC中啊
wuwuwuwu
  • 打赏
  • 举报
回复
taianmonkey 2004-04-29
HOWTO: Play an AVI File w/ an API Call to 16-bit Mmsystem.dll

Q136763


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Visual FoxPro for Windows, versions 3.0, 5.0, 6.0

--------------------------------------------------------------------------------


SUMMARY
There are several ways to play AVI (audio-visual interleave) files from Visual FoxPro. These include:



Placing the AVI file in a General field and then activating it.


Using a Custom control designed to play MCI (media control interface) devices.


Calling a Windows API function directly that will play the file for you.


The last technique, although more involved, gives the developer much more control over how the AVI file will appear during playback. This article explains how to play an AVI file using API functions contained in the Windows 16-bit Mmsystem.dll file.



MORE INFORMATION
The API function MCIEXECUTE can be used to access a variety of MCI devices including those required to play AVI files. MCIEXECUTE is located in the Windows file MMSYSTEM.DLL (typically located in the Windows System directory). Since MMSYSTEM is a 16 bit Dynamic Link Library, you must use the REGFN and CALLFN statements in FOXTOOLS.FLL to register this function (the DECLARE statement in Visual FoxPro can only be used with 32 bit DLL's).

Once the MCIEXECUTE function has been registered, you can use it to send a variety of MCI commands to open, play and close an AVI file. The syntax of the MCI command string allows you to control many attributes of the AVI playback window such as it's size, position, speed and direction (forward or reverse).

The following procedure describes how to create a Form that can be used to play an AVI file.



Open or switch to Visual FoxPro and open a new Form.


Place the following code in the INIT event of the form:

PUBLIC MCIEXE
SET LIBRARY TO FOXTOOLS.FLL
MCIEXE = REGFN("MCIExecute" ,"C","I", "MMSYSTEM.DLL") && Registers ;
the MCIEXECUTE API function using FOXTOOLS.FLL



Create a Command Button on the Form and place the following code in the click event of the button (you can make the Caption of the Button read something like "Play AVI File"):

cAVIFile = SYS(2004) + "TEST.AVI" && Specifies the path to, and ;
the name of the AVI file to be played
nRESULT = CALLFN(MCIEXE, "open " + cAVIFile + " TYPE AVIVIDEO alias ;
wind style popup") && Opens an instance of the MCI device type;
AVIVIDEO and gives it the alias name 'wind'
nRESULT = CALLFN(MCIEXE, "play wind wait") && Plays the AVI file ;
suspending further MCI command strings until this one is complete
nRESULT = CALLFN(MCIEXE,"close wind") && Closes the instance of the ;
MCI device driver specified by the alias 'wind'
NOTE: The above code assumes that the AVI file to be played is called TEST.AVI and is located in the Visual FoxPro directory. You should modify this line appropriately so that the variable AVIFILE will contain a string that contains the complete path and file name of the AVI file to be played. If the MCIEXECUTE is executed successfully, nRESULT will be 1.


Save and run the Form. Note that the AVI file will play when you click the Command Button created in step 3 above.


Now that you have successfully played an AVI file from Visual FoxPro, there are a number of things you can do to control how the playback window appears. For example adding the line:
nRESULT = CALLFN(MCIEXE, "put wind window at 300 200 164 147")
just prior to the line:
nRESULT = CALLFN(MCIEXE, "play wind wait")
in the click event of the Command Button allows you to control where the playback window will appear, and what it's dimensions will be. In this example the upper left hand corner of the window will be at pixel position 300, 200 (where the upper left hand corner of the screen is the origin of 0,0) and will have a width of 164 pixels and a height of 147 pixels.

Another example that demonstrates modifying the play back window is:
nRESULT = CALLFN(MCIEXE, "SET WIND SPEED 500")
Adding this line immediately prior to the line:
nRESULT = CALLFN(MCIEXE, "play wind wait")
in the click event of the Command Button allows you to control the speed at which the AVI file will play. In this example it will play a one half of its original speed (1 second to 500 milliseconds).

You can also control the direction in which the AVI file will play. Replace the code in the Click event of the Command Button with the following to demonstrate this ability:

cAVIFile = SYS(2004) + "TEST.AVI" && Specifies the path to, and ;
the name of the AVI file to be played
nRESULT = CALLFN(MCIEXE, "open " + cAVIFile + " TYPE AVIVIDEO alias ;
wind style popup") && Opens an instance of the MCI device type;
AVIVIDEO and gives it the alias name 'wind'
nRESULT = CALLFN(MCIEXE, "SET wind TIME FORMAT MILLISECONDS") && Sets;
the playback format to milliseconds (as opposed to frames)
nRESULT = CALLFN(MCIEXE, "PLAY wind WINDOW FROM 5000 TO 0 WAIT") ;
&& Note that the above line specifies to play the AVI file from time ;
position 5000 (milliseconds) to time position 0 (Beginning of the ;
file). If your AVI file is less than 5000 milliseconds in length, ;
adjust this line accordingly
nRESULT = CALLFN(MCIEXE,"close wind") && Closes the instance of the ;
MCI device driver specified by the alias 'wind'
There are many other things you can do to control the playback of AVI files using MCI Command Strings. For more information on these see Appendix F of the Microsoft Video for Windows User's Guide.

Additional query words:

Keywords : kbnokeyword kbvfp300 kbvfp500 kbvfp600
Issue type : kbhowto
Technology : kbVFPsearch kbAudDeveloper kbVFP300 kbVFP500 kbVFP600
  • 打赏
  • 举报
回复
相关推荐
发帖
VC/MFC
加入

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
帖子事件
创建了帖子
2004-04-29 09:14
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……