?? generic.cpp
字號:
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "generic.h"
#include "resource.h"
#if defined (win32)
#define IS_WIN32 TRUE
#else
#define IS_WIN32 FALSE
#endif
HINSTANCE hInst; // current instance
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
hInst = hInstance;
DialogBox(hInst, MAKEINTRESOURCE( IDD_DIALOG1 ), 0, (DLGPROC)gen);
return(0);
}
LRESULT CALLBACK gen( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
char username[255]="", serial[255]="1234567 - ", ch, buf[2];
char *upper;
int i, length;
unsigned long calc, con=1234567;
switch (uMsg)
{
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDGEN :
GetDlgItemText( hDlg, IDC_USERINPUT, username, 255);
// put key generation code here!!
length = strlen (username);
if (length < 8)
{
MessageBox (0, "User name must be 8 or more characters!", "Error", MB_OK );
break;
}
for (i=0 ; i < 5 ; i++)
{
calc = con;
ch = username[length-i-1];
calc += ch;
calc += ((i+1)*(i+1));
ch = username[i];
calc += ch;
calc = calc % 255;
sprintf(buf, "%x", calc);
strcat (serial, buf);
}
upper = _strupr (serial);
MessageBox (0, "Took into account 1234567 as first field of serial...", "Note", MB_OK );
//finish and bug out!
SetDlgItemText( hDlg, IDC_RESULTKEY, upper);
break;
case IDEXIT :
EndDialog( hDlg, IDEXIT);
break;
}
default : return(FALSE);
}
return(TRUE);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -