[推荐] 6droom 的新功能

  最近新项目要上线,时间真的成了问题,忙里偷闲上来发一篇日志,推荐一下 6droom 的一些新功能,顺便也记下一些开发中的心得 ... 具体的信息可以查看以下页面(http://www.6droom.com/docs/),其中最实用的功能应该算是我自己弄得一个 FireFox 和 IE6 / IE7 的扩展,这两个小插件可以帮大家更方便的搜索你想要搜索的东西(一个右键就搞定了,嘿嘿),大家不妨试试看,一定会满意的:)其中 IE 的扩展中我用到了一个操作 Windows 注册表的类,贴上来给大家共享一下吧,还不错,简单实用:

[@more@]

CRegKey.h :

#include
#include

using namespace std;

class CRegisterKey
{
public:
CRegisterKey();
virtual ~CRegisterKey();

public:
LONG Read(LPCTSTR pszKey , BYTE *pData , DWORD & dwLength);
LONG Read(LPCTSTR pszKey, string &sVal);
LONG Read(LPCTSTR pszKey , DWORD & dwVal);
LONG Write(LPCTSTR pszKey , const BYTE *pData , DWORD dwLength);
LONG Write(LPCTSTR pszKey , LPCTSTR pszVal);
LONG Write(LPCTSTR pszKey , DWORD dwVal);
void Close();
LONG Open(HKEY hKeyRoot , LPCTSTR pszPath , REGSAM dwAccess = KEY_ALL_ACCESS);

protected:
string m_sPath;
HKEY m_hKey;
};

CRegKey.cpp

#include "CRegKey.h"

//
// Construction/Destruction
//

CRegisterKey::CRegisterKey()
{
m_hKey = NULL;
}

CRegisterKey::~CRegisterKey()
{
Close();
}

LONG CRegisterKey::Open(HKEY hKeyRoot, LPCTSTR pszPath , REGSAM dwAccess)
{
DWORD dw;
m_sPath = pszPath;

return RegCreateKeyEx(hKeyRoot , pszPath , 0L , NULL , REG_OPTION_NON_VOLATILE ,
dwAccess , NULL , &m_hKey , &dw);
}

void CRegisterKey::Close()
{
if(m_hKey)
{
RegCloseKey(m_hKey);
m_hKey = NULL;
}
}

LONG CRegisterKey::Write(LPCTSTR pszKey, DWORD dwVal)
{
ASSERT(m_hKey);
ASSERT(pszKey);

return RegSetValueEx(m_hKey , pszKey , 0L , REG_DWORD , (CONST BYTE *) &dwVal ,
sizeof(DWORD));
}

LONG CRegisterKey::Write(LPCTSTR pszKey, LPCTSTR pszVal)
{
ASSERT(m_hKey);
ASSERT(pszKey);
ASSERT(pszVal);
ASSERT(AfxIsValidAddress(pszVal , strlen(pszVal) , FALSE));

return RegSetValueEx(m_hKey , pszKey , 0L , REG_SZ , (CONST BYTE *) pszVal ,
strlen(pszVal)+1);
}

LONG CRegisterKey::Write(LPCTSTR pszKey, const BYTE *pData, DWORD dwLength)
{
ASSERT(m_hKey);
ASSERT(pszKey);
ASSERT(pData && dwLength>0);
ASSERT(AfxIsValidAddress(pData , dwLength , FALSE));

return RegSetValueEx(m_hKey , pszKey , 0L , REG_BINARY , pData , dwLength);
}

LONG CRegisterKey::Read(LPCTSTR pszKey, DWORD &dwVal)
{
ASSERT(m_hKey);
ASSERT(pszKey);

DWORD dwType;
DWORD dwSize = sizeof(DWORD);
DWORD dwDest;

LONG lRet = RegQueryValueEx(m_hKey , pszKey , NULL , &dwType , (LPBYTE) &dwDest , &dwSize);

if(lRet == ERROR_SUCCESS)
dwVal = dwDest;

return lRet;
}

LONG CRegisterKey::Read(LPCTSTR pszKey, string &sVal)
{
ASSERT(m_hKey);
ASSERT(pszKey);

DWORD dwType;
DWORD dwSize = 512;
char string[512];

LONG lRet = RegQueryValueEx(m_hKey , pszKey , NULL , &dwType , (LPBYTE) string , &dwSize);

if(lRet == ERROR_SUCCESS)
sVal = string;

return lRet;
}

LONG CRegisterKey::Read(LPCTSTR pszKey, BYTE *pData, DWORD &dwLength)
{
ASSERT(m_hKey);
ASSERT(pszKey);

DWORD dwType;

return RegQueryValueEx(m_hKey , pszKey , NULL , &dwType , pData , &dwLength);
}

然后是 MingW 的生成 Windows 应用的用法:

gcc -c window.c

gcc -o window window.o -mwindows

第一步生成 Link 要用的 window.o 文件,第二步生成 window.exe 应用程序:)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8244769/viewspace-970722/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8244769/viewspace-970722/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值