📄 uz.cpp
字号:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <string.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>#include <commctrl.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <wchar.h> //SPLIT
#include <iostream>
#include <stdlib.h>
#include "uz.h"
#include "zip.h"
#include "unzip.h"
#include "dragdrop.h"
//#include "md5.h"
#define MAX_LOADSTRING 100
#define say(s) MessageBox(NULL,s,"Install",MB_OK | MB_ICONINFORMATION );
#define YesorNo(h,s) MessageBox(h,s,"Message in a box" , MB_SYSTEMMODAL|MB_ICONQUESTION|MB_YESNO);
#define Time 1
#define BAR 2
#define IDC_TRACKBAR IDC_TOOLBAR + 1
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
const int MAXF=5000;
//void DrawBitmap (HDC hdc, int xStart, int yStart, HBITMAP hBitmap);
void DrawBitmap (HWND h, int xStart, int yStart, HBITMAP hBitmap);
//int Sfiles(FILE *fp,char dir[MAX_PATH]);
int Sfiles(char dir[MAX_PATH]);
int Sfolder(FILE *fff,char dir[MAX_PATH]);
int fileordir(char dir[MAX_PATH]);
int gozip(HWND h,char outfile[260]);
void meter(HWND h,int cnt,char naame[260],char shortname[260]);
void index(char name[260]);
int UZI(char name[266],UINT msg);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK option(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
//unsigned char * getmd5(char *filename);
void PumpMessages();
int pass=0;
char Pword[129];
int BIG=0;
int ix,iy;
HWND wmain;
HBITMAP M1;
HBITMAP l1,l2;
HBITMAP ll1,ll2;
HBITMAP dle;
HZIP hz;
int mx=0,my=0,mm=0;
int Wx=295,Wy=299;
int ll=0,lll=0;
char state[256]="Idle";
char oldstate[256]="Idle";
char tampax[MAX_PATH];
int fd=0,fe=0,fi=0;
int rdraw=0;
int nextgo=0;
int level=0;
int broke=0;
int LOGER=0;
int ONTOP=0;
////////////////////////////////extern ///////////////////////////
//char SN[5000];
void getfiles( HWND hWnd );
//char * getfolder();
char * getname( const HWND hHandle);
//char * getfolder( const HWND hHandle);
char * getfolder(char mess[50], const HWND hHandle);
char * saveto(const HWND hHandle);
extern "C" char *WhoAmI(struct FileList *ptr);
extern "C" void WMDropFiles( WPARAM WParam, HWND hWnd);
unsigned long CheckFiles( char *na);
/********************************************/
extern "C" {
typedef unsigned int word32;typedef word32 uint32;struct MD5Context { uint32 buf[4]; uint32 bits[2]; unsigned char in[64];};
typedef struct MD5Context MD5_CTX;
void MD5Init(struct MD5Context *context);void MD5Update(struct MD5Context *context, unsigned char const *buf,unsigned len);void MD5Final(unsigned char digest[16], struct MD5Context *context);}
/********************************************/
extern "C" struct FileList {
char *lpFileName; // Name of dragged file
int x, y; // Position in client area dropped
BOOL inClient; // Dropped in client Flag
struct FileList *Next; // Points to next file in group dragged
};
extern "C" struct List {
struct List *Next; // Points to next node in List
struct FileList *FLptr; // Points to Filelist(s)
};
// Global variables
extern "C" struct List *liAllFiles; // Pointer to main list of file
///// move window
int am=0,amx=0,amy=0;
int tl=0,tr=0;
/////////////////////////////
char MEM[MAXF][MAX_PATH];
//char *MEM[MAX_PATH];
/////
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_UZ, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_UZ);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
if (msg.message == WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_UZ);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(CreateSolidBrush(RGB(0, 0, 0)));
//wcex.lpszMenuName = (LPCTSTR)IDC_UZ;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
ix=(GetSystemMetrics (SM_CXSCREEN)/2)-140;
iy=(GetSystemMetrics (SM_CYSCREEN)/2)-150;
hInst = hInstance; // Store instance handle in our global variable
//EXSTYLE WS_EX_ACCEPTFILES
/*
wmain= CreateWindow(szWindowClass, szTitle,
WS_POPUP ,
//|WS_BORDER,
//WS_OVERLAPPEDWINDOW,
// CW_USEDEFAULT, CW_USEDEFAULT,
ix,iy,
Wx,Wy,
//0, 800, 0, 600,
NULL, NULL, hInstance, NULL);
*/
wmain=CreateWindowEx(
WS_EX_TOPMOST| WS_EX_ACCEPTFILES,
szWindowClass, szTitle,
WS_POPUP ,
ix,iy,
Wx,Wy,
//0, 800, 0, 600,
NULL, NULL, hInstance, NULL);
if (!wmain)
{
wmain= CreateWindow(szWindowClass, szTitle,
WS_POPUP ,
ix,iy,
Wx,Wy,
//0, 800, 0, 600,
NULL, NULL, hInstance, NULL);
}
if (!wmain) {say("na"); return NULL; }
//AnimateWindow(wmain, 200,AW_VER_NEGATIVE);
AnimateWindow(wmain, 222,AW_ACTIVATE | AW_BLEND );
SetWindowPos(wmain,HWND_TOPMOST,ix,iy,Wx,Wy,SWP_SHOWWINDOW);
SendMessage(wmain,WM_PAINT,0,0);
ShowWindow(wmain, SW_SHOW);
//UpdateWindow(wmain);
return TRUE;
}
/***********************************/
void monitor(HWND h){ char coord[256];
HDC hdc;
RECT r;
hdc = GetDC(h); /* get DC */
/////////////////////////////////clean
if(rdraw!=0) { rdraw=0; DrawBitmap (h, 0, 0, M1); }
//////////////////////////////////////////
SetBkColor(hdc,RGB(0,0,0));
SetTextColor(hdc,RGB(211,211,211));
SetBkMode(hdc, TRANSPARENT);
sprintf(coord,"Folder: %3d ",fd);
TextOut(hdc,25,115,coord,strlen(coord));
sprintf(coord,"Files : %3d ",fi);
TextOut(hdc,25,132,coord,strlen(coord));
sprintf(coord,"Error : %3d ",fe);
TextOut(hdc,25,152,coord,strlen(coord));
/*
sprintf(coord,"%d ",fe);
TextOut(hdc,200,132,coord,strlen(coord));
*/
///*
SetBkColor(hdc,RGB(58,58,58));
SetTextColor(hdc,RGB(58,58,58));
SetBkMode(hdc, 2);
sprintf(coord,"Info: %s ",oldstate);
TextOut(hdc,80,175,coord,strlen(coord));
//*/
SetBkColor(hdc,RGB(0,0,0));
SetTextColor(hdc,RGB(222,222,222));
SetBkMode(hdc, TRANSPARENT);
sprintf(coord,"Info: %s ",state);
TextOut(hdc,83,175,coord,strlen(coord));
strcpy(oldstate,state);
/*
GetClientRect (h, &r) ;
r.left=200;
r.top=120;
r.right=250;
r.bottom=200;
DrawText(hdc,coord,strlen(coord),&r ,DT_NOCLIP);
*/
ReleaseDC(h, hdc);
}
/************************/
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
HDC PicDC;
char coord[100];
RECT rect;
unsigned long L=0;
/*drag drop*/
struct List* Ltemp;
struct FileList* FLtemp;
char *bufstring;
char ou[260];
char ou1[260];
char ou2[260];
char ou3[260];
char ou4[260];
int l;
//FILE *df;
char nano[MAX_PATH];
char ta1[260],ta2[260],ta3[260],ta4[260];
switch (message)
{
case WM_LBUTTONUP:
if(am==1) am=0;
break;;
case WM_MOUSEMOVE :
hdc = GetDC(hWnd); /* get DC */
mx=LOWORD(lParam);
my=HIWORD(lParam);
if(mx>225 && mx<240 && my>1 && my <18) strcpy(state,"Minimize ");
if(mx>269 && mx<284 && my>1 && my <18) strcpy(state,"Exit ");
if(mx>30 && mx<195 && my>0 && my<19) strcpy(state,"Move ");
if(mx>25 && mx<82 && my>43 && my <93) strcpy(state,"Select Folder ");
//if(mx>25 && mx<82 && my>43 && my <93) strcpy(state,"Select File ");
if(mx>94 && mx<140 && my>43 && my <93) strcpy(state,"Select File ");
if(mx>154 && mx<194 && my>43 && my <93) strcpy(state,"Option ");
if(mx>210 && mx<258 && my>43 && my <93) strcpy(state,"Compress ");
if(mx>45 && mx<86 && my>206 && my <248) strcpy(state,"About ");
if(mx>123 && mx<166 && my>206 && my <248) strcpy(state,"Error ");
if(mx>201 && mx<243 && my>206 && my <248) strcpy(state,"Reset ");
monitor(hWnd);
/*********************************************/
if(am==1 && mx>30 && mx<195 && my>0 && my<19) { ///move
GetWindowRect(hWnd, &rect);
tl=rect.left;
tr=rect.top;
MoveWindow(hWnd, tl+(mx-amx), tr+(my-amy), Wx, Wy, TRUE);
ShowWindow(hWnd, SW_SHOW );
//UpdateWindow(hWnd);
return 1;
}
else am=0;
/*********************************/
SetBkColor(hdc,RGB(0,0,0));
SetTextColor(hdc,RGB(255,255,0));
/*
sprintf(coord,"[%d,%d] ",mx,my);
TextOut(hdc,0,20,coord,strlen(coord));
*/
ReleaseDC(hWnd, hdc);
break;
case WM_LBUTTONDOWN:
mm=2;
//PlaySound (MAKEINTRESOURCE(IDR_WAVE1), NULL, SND_RESOURCE | SND_ASYNC) ;
hdc = GetDC(hWnd);
mx=LOWORD(lParam);
my=HIWORD(lParam);
///////////////////
if(BIG==1 && mx>0 && mx<49 && my>0 && my<48)
{
SetWindowPos(wmain,HWND_TOPMOST,ix,iy,Wx,Wy,SWP_SHOWWINDOW);
BIG=0;
DrawBitmap (hWnd, 0, 0, M1);
break;
}
if(BIG==0 && mx>202 && mx < 216 && my>1 && my < 20)//RESIZE
{
BIG=1;
GetWindowRect(hWnd, &rect);
tl=rect.left;
tr=rect.top;
SetWindowPos(wmain,HWND_TOPMOST,tl,tr,48,48,SWP_SHOWWINDOW);
DrawBitmap (hWnd, 0, 0, dle);
}
//////////////////////////////////
if(mx>30 && mx<195 && my>0 && my<19) { am=1; amx=mx; amy=my; break;}
else am=0;
if(mx>94 && mx<140 && my>43 && my <93) { //get 1 file
strcpy(tampax,getname(hWnd));
_splitpath(tampax, ou1, ou2,ou3, ou4);
strlwr(ou4);
//say(ou4);
if(ou4[1]=='z' && ou4[2]=='i' && ou4[3]=='p')//ses un zip decompresson
{
strcpy(ou1,ou3);
//strcat(ou1,".");
strcat(ou1,ou4);
//say(ou1);
UZI(nano,message);
break;
}
//say(tampax);
if(tampax[0]!=NULL) { strcpy(MEM[fi],tampax);
if(fd+fi<MAXF) fi++;
else fe++;
} //add one file if not empty
}
if(mx>25 && mx<82 && my>43 && my <93) { //get folder
strcpy(state,"WAIT ");
monitor(hWnd);
strcpy(tampax,getfolder("Select Folder",hWnd));
//df=fopen("test.txt","wt");
//Sfiles(df,tampax);
//fclose(df);
//say(tampax);
//Yo it work but not the right way moohaaaaa
if(tampax[0]!='
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -