Skip to content

Instantly share code, notes, and snippets.

@lniwn
lniwn / bitmap.cpp
Last active January 18, 2016 03:46
gdi 绘制图像
Gdiplus::Bitmap* gdiplus_bitmap = Gdiplus::Bitmap::FromFile(headImagePath_.c_str());
bool bOk = (gdiplus_bitmap && Gdiplus::Ok == gdiplus_bitmap->GetLastStatus());
if (!bOk) {
return false;
}
HBITMAP hBmp;
if (Gdiplus::Ok != gdiplus_bitmap->GetHBITMAP(Gdiplus::Color::White, &hBmp))
{
return false;
@lniwn
lniwn / 非HOOK方式替换FLASH模块
Last active March 29, 2016 09:44
使用优雅的方式自定义程序加载的flash插件
typedef HRESULT (STDCALL * fnDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID * ppvObj);
class CustomFlash
{
DWORD m_dwCookie;
CLSID m_clsid;
CComPtr<IClassFactory> m_spFactory;
HINSTANCE m_mod;
public:
@lniwn
lniwn / 屏蔽第三方库警告.h
Created March 30, 2016 05:03
屏蔽第三方库的编译警告
#pragma warning(push, 0)
#include ....
#pragma warning(pop)
@lniwn
lniwn / DllHelper.h
Last active June 2, 2016 14:45
使用c++11的function包装dll
#pragma once
#include <string>
#include <map>
#include <functional>
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
@lniwn
lniwn / AnyHelper.h
Created June 14, 2016 02:39
C++11实现的可以包容所有数据类型的Any容器
#pragma once
#include <memory>
#include <typeindex>
namespace C0xHelper
{
class Any
{
public:
@lniwn
lniwn / CppShellCommonFileDialog.cpp
Created June 27, 2016 02:51
创建文件选择对话框
/************************************ Module Header ******************************\
Module Name:  CppShellCommonFileDialog.cpp
Project:      CppShellCommonFileDialog
Copyright (c) Microsoft Corporation.
 
The code sample demos the use of shell common file dialogs.
 
This source is subject to the Microsoft Public License.
See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
All other rights reserved.
@lniwn
lniwn / VCDetector.cpp
Created July 19, 2016 09:12
检测系统是否安装vc运行时库
#include "stdafx.h"
// Constants used to represent the MSI product CODES for all of the runtimes
const LPCTSTR _vc2008x86Code = TEXT("{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}");
const LPCTSTR _vc2008x64Code = TEXT("{350AA351-21FA-3270-8B7A-835434E766AD}");
const LPCTSTR _vc2008SP1x86Code = TEXT("{9A25302D-30C0-39D9-BD6F-21E6EC160475}");
const LPCTSTR _vc2008SP1x64Code = TEXT("{8220EEFE-38CD-377E-8595-13398D740ACE}");
const LPCTSTR _vc2010x86Code = TEXT("{196BB40D-1578-3D01-B289-BEFC77A11A1E}");
const LPCTSTR _vc2010x64Code = TEXT("{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}");
@lniwn
lniwn / ClearIECookie.h
Created August 22, 2016 07:07
清理WinInet会话级cookie
// http://stackoverflow.com/questions/6375540/how-to-clear-cookie-through-wininet-function
::InternetSetOption(NULL, INTERNET_OPTION_END_BROWSER_SESSION, NULL, 0);
@lniwn
lniwn / CUrlEncode.h
Created August 22, 2016 07:08
Url编解码类
#pragma once
#include <xstring>
#include <string>
//url编码类
class CUrlEncode
{
public:
void StringToWstring(std::wstring& szDst, std::string str)
@lniwn
lniwn / DesktopUtils.cpp
Created February 8, 2017 07:22
获取桌面进程窗口句柄
HWND WindowDeskPopUtils::GetDeskWindow()
{
HWND hSysView32 = NULL;
// 先按win7方式查找
HWND hWnd = NULL;
do
{
hSysView32 = ::FindWindowEx(NULL, hWnd, _T("Progman"), _T("Program Manager"));
if (hSysView32)