在Windows上编写代码的时候,都应该使用Unicode,但是往往在项目中,总会遇到一些 不方便的地方,例如,读写磁盘,加密等等。因此,以下给出2个函数,用于多字节与宽自己的转换,主要使用Windows提供的 WideCharToMultiByte与MultiByteToWideChar函数。123456789101112131415// 将Unicode字符串转换为Ansicode字符串void ConvertUnicodeToAnsi(wchar_t* source, char* dest){ int len = 0; len = WideCharToMultiByte(CP... Read More
posted @ 2013-03-20 22:08 godjob Views(639) Comments(0) Diggs(0) Edit
C++获得计算机网卡MAC地址,以下程序采用静态加载的办法来实现的,建议在实际项目中,动态加载iphlpapi.dll,来实现获得网卡MAC地址,因为不是每台计算机都有iphlpapi.dll这个问题的,如果是静态加载的话,就可能直接报错。代码如下:#include <stdio.h>#include <Windows.h>#include <iphlpapi.h>#pragma comment(lib, "iphlpapi.lib")void main(){ IP_ADAPTER_INFO adapter[5]; DWORD bufle Read More
posted @ 2013-03-20 22:07 godjob Views(409) Comments(0) Diggs(0) Edit
#include <stdio.h>#include <stdlib.h>#include <memory.h>#define POLY 0x04C11DB7Lunsigned long get_sum_poly( unsigned char top_byte ){ /// sum all the polys at various offsets unsigned long sum_poly = top_byte << 24; for( int j = 0; j < 8; ++ j ) { /// check the top bit if( Read More
posted @ 2013-03-20 22:03 godjob Views(2483) Comments(0) Diggs(0) Edit