Skip to content

Instantly share code, notes, and snippets.

@lxfly2000
lxfly2000 / Extract.cpp
Created October 7, 2017 05:13
使用Windows自带的API解压zip文件。
#include<Windows.h>
#include<ShObjIdl.h>
#include<ShlObj.h>
#include<fstream>
LPWSTR TrimQuote(LPWSTR str)
{
int ifrom = 0, ito = 0;
while (str[ifrom])
{
if (str[ifrom] != '\"')
@lxfly2000
lxfly2000 / readmem.cpp
Created November 3, 2017 09:12
任意进程的内存读取/修改
#include<iostream>
#include<string>
#include<Windows.h>
#include<TlHelp32.h>
DWORD QueryFirstPIDOfProcessName(LPCWSTR pn)
{
PROCESSENTRY32 pe;
pe.dwSize = sizeof pe;
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
for (BOOL notend = Process32First(hProcessSnap, &pe); notend; notend = Process32Next(hProcessSnap, &pe))
//手动解析32位浮点数(1位符号+8位阶码(指数)+23位尾数)
#define BITS_SIGN 1
#define BITS_EXP 8
#define BITS_TAIL 23
#include<stdio.h>
#include<string.h>
#include<math.h>
#define GetBit(n,bit) (((n)>>(BITS_SIGN+BITS_EXP+BITS_TAIL-1-(bit)))&1)
@lxfly2000
lxfly2000 / cvdiff.cpp
Created January 27, 2018 05:50
比较两个图像是否相似或一致。(https://pan.baidu.com/s/1htqQ5pi
//采用OpenCV轮廓匹配判断两个简单图片是否相似或一致
#include <iostream>
#include <opencv/cv.hpp>
//测试图片B是否与图片A相似,越接近0表示越相似,反之不相似
//IplImage到Mat转换:http://blog.sina.com.cn/s/blog_534497fd01015k7z.html
//参考:http://blog.csdn.net/qq_18343569/article/details/48004201
//参考:http://blog.csdn.net/qq_15947787/article/details/72773893
double TestDifference(const IplImage *imgA, const IplImage *imgB, int method = CV_CONTOURS_MATCH_I1,
double thresholdA1 = 50, double thresholdA2 = 60, double thresholdB1 = 50, double thresholdB2 = 60)
@lxfly2000
lxfly2000 / officevl.js
Last active March 28, 2018 11:39
Office 2016 激活脚本(注意保存为GBK编码)
//该脚本用于激活 Office 2016.
//This script is written for activating Office 2016.
//如果有Bug或者任何疑问请邮件联系 [email protected] 或微博 lxfly2000.
//Any bugs or questions please contact me at [email protected] or lxfly2000 on Weibo.
//使用方法:在管理员模式下执行命令行“officevl <KMS服务器>”
//Usage: Run this command with Administrator "officevl <KMS Server>"
var sn="XQNVK-8JYDB-WJ9W3-YJ8YR-WFG99";//激活序列号,可到 https://technet.microsoft.com/zh-cn/library/dn385360(v=office.16).aspx 上找。
var kmsserver="";//在此处填入KMS服务器地址
if(WScript.Arguments.length>0)
//pmd参考:https://github.com/mistydemeo/pmdmini
#pragma comment(lib,"PMDWin\\PMDWin.lib")
#pragma comment(lib,"mfreadwrite.lib")
#pragma comment(lib,"mfplat.lib")
#pragma comment(lib,"mfuuid.lib")
#include<Windows.h>
#include<mfidl.h>
#include<mfapi.h>
#include<mfreadwrite.h>
#define _WINDOWS
@lxfly2000
lxfly2000 / tktest.pyw
Last active June 1, 2018 03:34
测试Python Tkinter的功能
#coding=utf-8
import tkinter
import tkinter.ttk
import tkinter.messagebox
tkMain=tkinter.Tk()
def canvas_on_resize(event):
tkMain.title("Canvas size: %dx%d"%(event.width,event.height))
#具有每个图形的元数据信息,因此不能重复创建,只能修改图形属性
@lxfly2000
lxfly2000 / mfencode.cpp
Last active October 17, 2018 17:22
用MF转换音频文件到MP3
//用Windows Media Foundation将任何Windows支持的音频文件转换成MP3格式文件,仅限Windows 8(NT6.2)及以上操作系统。
#include<new>
#include<iostream>
#include<string>
#include<locale.h>
#include<Windows.h>
#include<mfapi.h>
#include<mfidl.h>
#include<Shlwapi.h>
#pragma comment(lib,"mfplat.lib")
@lxfly2000
lxfly2000 / factorial.cpp
Created July 22, 2018 10:18
大数阶乘
#include<Windows.h>
#include<iostream>
#include<string>
unsigned short c[22167];
void testmain(std::string&param)
{
bool enable_cout = true;
if (param[0] == '@')
{
enable_cout = false;
@lxfly2000
lxfly2000 / test_bili.py
Last active August 4, 2018 09:21
B站下架了哪些番?
#coding:utf-8
#Python 3.6, 3.7
#该脚本目前需要配合AnimeSchedule一起使用。(https://github.com/lxfly2000/AnimeSchedule)
import json
import urllib.request
#测试有效性,成功返回1,失败返回0,非B站网页返回2
def testBilibiliURL(title,src_url):