⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wd_ustr.h

📁 国内文件驱动编程知名人物蔡大侠的教程源代码
💻 H
字号:
// header file of wd_ustr

#ifndef _WD_HEADER_WDF_USTR_

#define _WD_HEADER_WDF_USTR_

#include "wdf.h"	//< 依赖wdf.h
#include <stdio.h> 

extern wd_ustr g_reg_path;
_inline wd_ustr *wd_reg_path()
{
	return &g_reg_path;
}

_inline wd_void wd_ustr_init(in out wd_ustr* str,in const wd_wchar* chars)
{	RtlInitUnicodeString(str,chars);	};

_inline wd_void wd_ustr_init_em(
				in out wd_ustr*str,
				in wd_wchar *chars,
				in wd_size size)
{	RtlInitEmptyUnicodeString(str,chars,size);	};

_inline wd_long wd_ustr_cmp(in_ const wd_ustr *str1,
							in_ const wd_ustr *str2,
							in_ wd_bool case_insen)
{	return RtlCompareUnicodeString(str1,str2,case_insen);	}

_inline wd_void wd_ustr_copy(in_ wd_ustr *dest,
							 in_ const wd_ustr *src)
{	RtlCopyUnicodeString(dest,src);	};

_inline wd_ushort wd_ustr_length(in_ const wd_ustr *str)
{	return str->Length;	}

_inline void wd_ustr_length_set(in_ out_ wd_ustr *str, in_ wd_ushort len)
{	str->Length = len;	}

_inline wd_ushort wd_ustr_max_length(in_ const wd_ustr *str)
{	return str->MaximumLength;	}

_inline wd_wchar* wd_ustr_buf(in_ const wd_ustr *str)
{	return ((wd_ustr *)str)->Buffer;	}

_inline wd_bool wd_ustr_set(in_ out_ wd_ustr *ustr,in_ const wd_wchar *str)
{
	// 设置字符串,其实也是拷贝
	if( (wcslen(str) + 1) * sizeof(wd_wchar) >= ustr->MaximumLength )
		return wd_false;
	wcscpy(ustr->Buffer,str);
	ustr->Length = ( wd_ushort )( ( wcslen( str ) + 1 )*sizeof( wd_wchar ) );
	return wd_true;
}

typedef void * wd_ustr_h;
wd_ustr_h wd_ustr_h_alloc(const wd_wchar *str);
wd_ustr_h wd_ustr_h_alloc_from_ustr(const wd_ustr *ustr);
wd_void wd_ustr_h_free(wd_ustr_h str);
wd_bool wd_ustr_h_set(wd_ustr_h str,const wd_wchar *content);
wd_bool wd_ustr_h_set_by_ustr(wd_ustr_h str,const wd_ustr *content);
wd_void wd_ustr_h_copy(wd_ustr_h dst,const wd_ustr_h src);
wd_void wd_ustr_appd_int(wd_int num);						// empty
wd_bool wd_ustr_appd(wd_ustr_h dst,const wd_wchar *str);	// empty
wd_bool wd_ustr_appd_ustr(wd_ustr_h dst,wd_ustr *str);		// empty	
wd_bool wd_ustr_appd_ustr_test();			
wd_bool wd_ustr_appd_ustr_h(wd_ustr_h dst,wd_ustr_h str);	// empty
wd_wchar *wd_ustr_h_buf(wd_ustr_h str);
wd_ustr *wd_ustr_h_ustr(wd_ustr_h str);
wd_ulong wd_ustr_h_len(wd_ustr_h str);

// 测试函数
wd_void wd_ustr_test(); 

#endif // _WD_HEADER_WDF_USTR_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -