Skip to content

Instantly share code, notes, and snippets.

@lniwn
lniwn / flash-activex.cpp
Created July 25, 2020 08:25 — forked from t-mat/flash-activex.cpp
Windows: ActiveXを利用して、Flashをウィンドウ内に表示する
// flash-to-directx : Library to embed Adobe Flash movies to DirectX-based applications.
// https://code.google.com/p/flash-to-directx/
//
// swfui : Adobe Flash User Interface
// https://code.google.com/p/swfui/
//
// C++ and Flash: Send or get data from/to a SWF using C++ and ActiveX in Win32
// http://www.codeproject.com/Articles/269829/Communicate-with-Flash-Send-or-Get-data-from-to-a
//
#include <windows.h>
@lniwn
lniwn / CMakeLists.txt
Created December 19, 2018 06:56
CMake示例
# Compatibility
cmake_minimum_required(VERSION 2.6)
if(WIN32)
# Windows XP compatible platform toolset. Must be set before project(),
# otherwise change of CMAKE_*_TOOLSET will take no effect.
# We get VS version from the generator name because neither MSVC* nor other
# variables that describe the compiler aren't available before project().
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)")
# Note: "v110_xp" is for Visual Studio 11 2012, which is unsupported.
@lniwn
lniwn / decss.c
Created September 8, 2018 14:02
dvd解密
/*****************************************************************************
* css_unscramble.c : unscrambling function
*****************************************************************************
* Copyright (C) 1999 Derek Fawcus
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
@lniwn
lniwn / getIeHandle
Last active December 8, 2017 08:19
get ie hwnd
// level: IE窗口的层级,一共三级
// 0: Shell Embedding
// 1: Shell DocObject View
// 2: Internet Explorer_Server
HWND getIEHandle(QAxWidget* pWidget, int level)
{
assert(pWidget);
CComPtr<IWebBrowser2> pWebBrowser2;
pWidget->queryInterface( IID_IWebBrowser2, (void**)&pWebBrowser2 );
assert(pWebBrowser2);
@lniwn
lniwn / fstream.cpp
Created December 4, 2017 04:54
Read file-contents into a string in C++
std::ifstream ifs("myfile.txt");
std::string content( (std::istreambuf_iterator<char>(ifs) ),
(std::istreambuf_iterator<char>() ) );
@lniwn
lniwn / DynamicCxxProperty.h
Last active January 2, 2018 10:09
C++属性
template <typename value_t>
class IProperty_Forward {
public:
virtual ~IProperty_Forward() {}
virtual const value_t& Read() = 0;
virtual void Set(const value_t& value) = 0;
};
template <typename value_t, typename owner_t, typename getter_t, typename setter_t>
class TProperty_Forwarder: public IProperty_Forward<value_t>
@lniwn
lniwn / EnableHighDPISupport.cpp
Created October 13, 2017 08:46
Windows应用支持高分屏
void EnableHighDPISupport() {
// Enable per-monitor DPI for Win10 or above instead of Win8.1 since Win8.1
// does not have EnableChildWindowDpiMessage, necessary for correct non-client
// area scaling across monitors.
PROCESS_DPI_AWARENESS process_dpi_awareness =
GetVersion() >= VERSION_WIN10 ? PROCESS_PER_MONITOR_DPI_AWARE
: PROCESS_SYSTEM_DPI_AWARE;
if (!SetProcessDpiAwarenessWrapper(process_dpi_awareness)) {
// For windows versions where SetProcessDpiAwareness is not available or
// failed, try its predecessor.
@lniwn
lniwn / macro-default-value.cpp
Created September 22, 2017 09:28
C++宏默认参数
enum
{
plain = 0,
bold = 1,
italic = 2
};
void PrintString(const char* message, int size, int style)
{
}
@lniwn
lniwn / CreateRegionFromImage.cpp
Last active June 16, 2017 03:04
从图片创建窗口有效区
BYTE* Get24BitPixels(HBITMAP pBitmap, WORD *pwWidth, WORD *pwHeight)
{
// a bitmap object just to get bitmap width and height
BITMAP bmpBmp;
// pointer to original bitmap info
LPBITMAPINFO pbmiInfo;
// bitmap info will hold the new 24bit bitmap info
BITMAPINFO bmiInfo;
@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)