
/ Copyright (c) MediaAreanet SARL All Rights Reserved
Use of this source code is governed by a BSD-style license that can
be found in the Licensehtml file in the root of the source tree
/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Example for MediaInfoLib
// Command line version
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#ifdef MEDIAINFO_LIBRARY
#include "MediaInfo/MediaInfoh" //Staticly-loaded library (lib or a or so)
#define MediaInfoNameSpace MediaInfoLib;
#else //MEDIAINFO_LIBRARY
#include "MediaInfoDLL/MediaInfoDLLh" //Dynamicly-loaded library (dll or so)
#define MediaInfoNameSpace MediaInfoDLL;
#endif //MEDIAINFO_LIBRARY
#include <iostream>
#include <iomanip>
using namespace MediaInfoNameSpace;
#ifdef __MINGW32__
#ifdef _UNICODE
#define _itot _itow
#else //_UNICODE
#define _itot itoa
#endif //_UNICODE
#endif //__MINGW32
int main (int /argc/, Char /argv[]/)
{
//Information about MediaInfo
MediaInfo MI;
String To_Display=MIOption(__T("Info_Version"), __T("0713;MediaInfoDLL_Example_MSVC;0713"))c_str();
To_Display += __T("\r\n\r\nInfo_Parameters\r\n");
To_Display += MIOption(__T("Info_Parameters"))c_str();
To_Display += __T("\r\n\r\nInfo_Codecs\r\n");
To_Display += MIOption(__T("Info_Codecs"))c_str();
//An example of how to use the library
To_Display += __T("\r\n\r\nOpen\r\n");
MIOpen(__T("Exampleogg"));
To_Display += __T("\r\n\r\nInform with Complete=false\r\n");
MIOption(__T("Complete"));
To_Display += MIInform()c_str();
To_Display += __T("\r\n\r\nInform with Complete=true\r\n");
MIOption(__T("Complete"), __T("1"));
To_Display += MIInform()c_str();
To_Display += __T("\r\n\r\nCustom Inform\r\n");
MIOption(__T("Inform"), __T("General;Example : FileSize=%FileSize%"));
To_Display += MIInform()c_str();
To_Display += __T("\r\n\r\nGet with Stream=General and Parameter=\"FileSize\"\r\n");
To_Display += MIGet(Stream_General, 0, __T("FileSize"), Info_Text, Info_Name)c_str();
To_Display += __T("\r\n\r\nGetI with Stream=General and Parameter=46\r\n");
To_Display += MIGet(Stream_General, 0, 46, Info_Text)c_str();
To_Display += __T("\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n");
#ifdef __MINGW32__
Char C1=new Char[33];
_itot (MICount_Get(Stream_Audio), C1, 10);
To_Display +=C1;
delete[] C1;
#else
toStringStream SS;
SS << std::setbase(10) << MICount_Get(Stream_Audio);
To_Display += SSstr();
#endif
To_Display += __T("\r\n\r\nGet with Stream=General and Parameter=\"AudioCount\"\r\n");
To_Display += MIGet(Stream_General, 0, __T("AudioCount"), Info_Text, Info_Name)c_str();
To_Display += __T("\r\n\r\nGet with Stream=Audio and Parameter=\"StreamCount\"\r\n");
To_Display += MIGet(Stream_Audio, 0, __T("StreamCount"), Info_Text, Info_Name)c_str();
To_Display += __T("\r\n\r\nClose\r\n");
MIClose();
#ifdef _UNICODE
std::wcout << To_Display;
#else
std::cout << To_Display;
#endif
return 0;
}
//
// By buffer example
//
/
//---------------------------------------------------------------------------
//Note: you can replace file operations by your own buffer management class
#include <stdioh>
int main (int argc, Char argv[])
{
//From: preparing an example file for reading
FILE F=fopen("Exampleogg", "rb"); //You can use something else than a file
if (F==0)
return 1;
//From: preparing a memory buffer for reading
unsigned char From_Buffer=new unsigned char[7188]; //Note: you can do your own buffer
size_t From_Buffer_Size; //The size of the read file buffer
//From: retrieving file size
fseek(F, 0, SEEK_END);
long F_Size=ftell(F);
fseek(F, 0, SEEK_SET);
//Initializing MediaInfo
MediaInfo MI;
//Preparing to fill MediaInfo with a buffer
MIOpen_Buffer_Init(F_Size, 0);
//The parsing loop
do
{
//Reading data somewhere, do what you want for this
From_Buffer_Size=fread(From_Buffer, 1, 7188, F);
//Sending the buffer to MediaInfo
size_t Status=MIOpen_Buffer_Continue(From_Buffer, From_Buffer_Size);
if (Status&0x08) //Bit3=Finished
break;
//Testing if there is a MediaInfo request to go elsewhere
if (MIOpen_Buffer_Continue_GoTo_Get()!=(MediaInfo_int64u)-1)
{
fseek(F, (long)MIOpen_Buffer_Continue_GoTo_Get(), SEEK_SET); //Position the file
MIOpen_Buffer_Init(F_Size, ftell(F)); //Informing MediaInfo we have seek
}
}
while (From_Buffer_Size>0);
//Finalizing
MIOpen_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finnish some work
//Get() example
String To_Display=MIGet(Stream_General, 0, __T("Format"));
#ifdef _UNICODE
std::wcout << To_Display;
#else
std::cout << To_Display;
#endif
}
/
如图,我要获取HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\typedurls 这个的URL1 2 3中的网址信息。
HKEY hKey;
RegOpenKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Internet Explorer\\TypedURLs",&hKey);//打开键
char szpath[500];
DWORD dwSize = sizeof(szpath);
RegQueryValueEx(hKey,"url1",NULL,NULL,(LPBYTE)szpath,&dwSize);//提取内容
char str[500];
wsprintf(str,"url1=%s\0",szpath);
printf("%s\n",str);
用这个代码段可以获取第一个URL1的值,怎么样遍历剩下URL呢?
------解决方案--------------------
regedit 的命令行参数
filename 导入 reg 文件进注册表
/s 导入 reg 文件进注册表(安静模式)
/e 导出注册表文件
例:regedit /e filenamereg HKEY_LOCAL_MACHINE\SYSTEM
/L:system 指定 systemdat
/R:user 指定 userdat
/C 压缩 [文件名] (Windows 98)
REGEDIT[/L:system][/R:user]filename1
REGEDIT[/L:system][/R:user]/C filename2
REGEDIT[/L:system][/R:user]/E filename3 [regpath]
其中:
/L:system 指定systemdat文件的存放位置。
/R:user 指定userdat文件的存放位置。
filename1 指定引入到注册表数据库的文件名。
/C filename2 指定形成注册表数据库的文件名。
/E filename3 指定导出注册表文件的文件名。
regpath 指定导出注册表文件的开始关键字(缺省为全部关键字)
这个程序应该满足你的要求吧。
#include <stdioh>
#include <conioh>
int main(void)
{
while (1)
{
if (!kbhit())
printf("1");
else
{
char c = getch();
if (c == 'a')
{
putchar('2');
getch();
}
}
}
return 0;
}
UTF-8是一种多字节编码的字符集,表示一个Unicode字符时,它可以是1个至多个字节,在表示上有规律:
1字节:0xxxxxxx
2字节:110xxxxx
10xxxxxx
3字节:1110xxxx
10xxxxxx
10xxxxxx
4字节:11110xxx
10xxxxxx
10xxxxxx
10xxxxxx
这样就可以根据上面的特征对字符串进行遍历来判断一个字符串是不是UTF-8编码了。应该指出的是UTF-8字符串的各个字节的取值有一定的范围,并不是所有的值都是有效的UTF-8字符,但是一般的应用的情况下这样的判断在对足够长的字符串及是比较精确了,而且实现也比较简单。具体的字节取值范围可以参见"Unicode
Explained"一书中的643。
bool
IsUTF8(const
void
pBuffer,
long
size)
{
bool
IsUTF8
=
true;
unsigned
char
start
=
(unsigned
char)pBuffer;
unsigned
char
end
=
(unsigned
char)pBuffer
+
size;
while
(start
<
end)
{
if
(start
<
0x80)
//
(10000000):
值小于0x80的为ASCII字符
{
start++;
}
else
if
(start
<
(0xC0))
//
(11000000):
值介于0x80与0xC0之间的为无效UTF-8字符
{
IsUTF8
=
false;
break;
}
else
if
(start
<
(0xE0))
//
(11100000):
此范围内为2字节UTF-8字符
{
if
(start
>=
end
-
1)
break;
if
((start[1]
&
(0xC0))
!=
0x80)
{
IsUTF8
=
false;
break;
}
start
+=
2;
}
else
if
(start
<
(0xF0))
//
(11110000):
此范围内为3字节UTF-8字符
{
if
(start
>=
end
-
2)
break;
if
((start[1]
&
(0xC0))
!=
0x80
||
(start[2]
&
(0xC0))
!=
0x80)
{
IsUTF8
=
false;
break;
}
start
+=
3;
}
else
{
IsUTF8
=
false;
break;
}
}
return
IsUTF8;
}
UTF-
16以16位为单元对UCS进行编码。对于小于0x10000的UCS码,UTF-16编码就等于UCS码对应的16位无符号整数。对于不小于
0x10000的UCS码,定义了一个算法。不过由于实际使用的UCS2,或者UCS4的BMP必然小于0x10000,所以就目前而言,可以认为UTF
-16和UCS-2基本相同。但UCS-2只是一个编码方案,UTF-16却要用于实际的传输,所以就不得不考虑字节序的问题。
我估计你分数给的在高也没人回答。来个这样的代码太麻烦了。而且百度金币用处也不大。
不过,我可以写几个鼠标函数给你参考一下。
首先了解一下鼠标的中断。
_ax=0x01
表示显示光标
_ax=0x02
停止显示光标
_ax=0x03
读取光标位置与案件
_ax=0x04
设置光标位置
所以啊。根据这四个中断,有以下几个函数
----------------------------------------------------
void
mouseon(void)//鼠标光标显示
{
_ax
=
0x01;
geninterrupt(0x33);
}
----------------------------------------------------
void
mouseoff(void)//鼠标光标隐藏
{
_ax
=
0x02;
geninterrupt(0x33);
}
---------------------------------------------------
void
mousesetxy(int
x,int
y)//设置当前位置
{
_cx
=
x,
_cd
=
y;
_ax
=
0x04;
geninterrupt(0x33);
}
---------------------------------------------------
int
leftpress(void)//鼠标左键按下
{
_ax
=
0x33;
geninterrupt(0x33);
return(_bx&1);
}
-----------------------------------------------------
鼠标右键的应该也会了吧。不过要return(_bx&2);
-----------------------------------------------------
void
mousegetxy(void)//得到当前位置
{
_ax
=
0x33;
geninterrupt(0x33);
mousex
=
_cx;
mousey
=
_dx;
}
---------------------------------------------------------------
最好要复制粘贴,打字打得手疼。
以上就是关于如何用c++调用mediainfo获取信息全部的内容,包括:如何用c++调用mediainfo获取信息、如何用C语言获取windows注册表信息、C语言获取按键信息函数等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)