12345678910111213141516171819202122232425262728293031323334
#include <windows.h> #include <string.h> #include <iostream> #include <fstream> using namespace std; // Returns an empty string if dialog is canceled string openfilename(char *filter = "Select file (*.bin)\0*.*\0", HWND owner = NULL) { OPENFILENAME ofn; char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = owner; ofn.lpstrFilter = filter; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = "bin"; string fileNameStr; if ( GetOpenFileName(&ofn) ) fileNameStr = fileName; return fileNameStr; } int main() { cout << openfilename().c_str(); fstream openfilename; openfilename.open("save.bin",fstream::in | fstream::out | fstream::binary); openfilename.seekg(0x16); openfilename.put(0xFF); openfilename.seekg(0x4A); openfilename.put(0x0F); openfilename.seekg(0x4B); openfilename.put(0x27); openfilename.close(); }
12
fstream openfilename; openfilename.open(openfilename().c_str(),fstream::in | fstream::out | fstream::binary);