1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include <fstream>
#include <windows.h>
#include <bitset>
#define textfield1 0
#define textfield2 1
#define push 2
#define label 3
#define label2 4
using namespace std;
LRESULT CALLBACK P(HWND A,UINT B,WPARAM C,LPARAM D){
switch(B){case WM_CREATE:
CreateWindow("edit","",WS_CHILD|WS_VISIBLE,5,50,980,700,A,(HMENU)textfield1,NULL,NULL);
CreateWindow("edit","",WS_CHILD|WS_VISIBLE,55,10,786,25,A,(HMENU)textfield2,NULL,NULL);
CreateWindow("static","Adress:",WS_CHILD|WS_VISIBLE,5,10,50,25,A,(HMENU)label,NULL,NULL);
CreateWindow("static","This File Binary codes:",WS_CHILD|WS_VISIBLE,5,35,170,15,A,(HMENU)label2,NULL,NULL);
CreateWindow("button","Show Binary Codes",WS_VISIBLE|WS_CHILD,845,10,140,25,A,(HMENU)push,NULL,NULL);
break;
case WM_COMMAND:
switch(LOWORD(C)){
case push:
char *adress,*b;
GetDlgItemText(A,textfield1,adress,TRUE);
ifstream file;
file.open(adress,ifstream::binary);
long filesize;
file.seekg(0,ifstream::end);
filesize=file.tellg();
file.seekg(0);
b=new char[filesize];
file.read(b,filesize);
for(int i=0;i<filesize;i++){
bitset<8>binary(b[i]);
for(int j=0;j<8;j++){
if(!SetDlgItemInt(A,textfield2,binary[j],TRUE))
MessageBox(NULL,"Not Success binary convert","ERROR",MB_OK|MB_IConerror);
}
}
break;
}
break;
case 0x2:
PostQuitMessage(0);
break;
default:
return DefWindowProc(A,B,C,D);
}
return 0;}
char title[]="File Binary Codes";
int WINAPI WinMain(HINSTANCE A,HINSTANCE B,LPSTR C,int d){
HWND E;
MSG F;
WNDCLASS G={0};
G.hInstance=A;
G.lpszClassName=title;
G.lpfnWndProc=P;
G.lpfnWndProc=P;
G.hbrBackground=GetSysColorBrush(COLOR_3DFACE);
RegisterClass(&G);
CreateWindow(G.lpszClassName,title,0xcf0000|WS_VISIBLE,50,10,1000,800,0,0,A,0);
while(GetMessage(&F,NULL,0,0)){
TranslateMessage(&F);
DispatchMessage(&F);
}
return F.wParam;
}
|