int main(int argc, char* argv[]) { std::string workingDir = getexepath() + "/../DB"; workingDir = "/home/bele/git/arduino-mqtt-sn-gateway/cmake-build-debug/DB"; persistent.setRootPath((char *) workingDir.c_str()); setup(); while(true){ gateway.loop(); } }
int main(int argc, char *argv[]) { std::string cur_dir = getexepath(); chdir (cur_dir.c_str()); std::ifstream is("container_list"); std::istream_iterator<int> start(is), end; std::vector<int> numbers(start, end); std::copy(numbers.begin(), numbers.end(), std::ostream_iterator<int>(std::cout, "\n")); }
int main(int argc, char *argv[]) { if ( argc != 2 ) { /* display usage on error stream */ fprintf(stderr, "usage: znm-project project_name\n\n"); exit(1); /* exit status of the program : non-zero for errors */ } if ( QString("--help") == argv[1] ) { printf ("usage: znm-project project_name\nCreates a zenom project.\n\n"); exit(0); /* exit status of the program : non-zero for errors */ } QDir projectDir; if ( projectDir.exists( argv[1] ) ) { fprintf(stderr, "The project cannot be created because '%s' folder already exists.\n", argv[1]); exit(1); /* exit status of the program : non-zero for errors */ } projectDir.mkpath( argv[1] ); projectDir.cd( argv[1] ); QFileInfo programFileInfo( getexepath() ); QString projectName( QFileInfo(argv[1]).fileName() ); createFile( programFileInfo.dir().filePath("znm-project-main.template"), projectDir.filePath("main.cpp"), projectName ); createFile( programFileInfo.dir().filePath("znm-project-makefile.template"), projectDir.filePath("Makefile"), projectName ); // Open project file to write QFile configFile( projectDir.filePath(QString("%1.znm").arg(projectName)) ); if ( !configFile.open(QFile::WriteOnly | QFile::Text) ) { fprintf(stderr, "The project cannot be created because the file '%s' could not be opened.\n", configFile.fileName().toAscii().data()); exit(1); /* exit status of the program : non-zero for errors */ } configFile.close(); return 0; }
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) { switch (lParam) { case INJECT_DLL:{ if (getwindowtext(hwnd) == "Diablo II") { string path = getexepath(hwnd); if (path == "") MessageBox(hwnd, str_to_wstr("Could not get Diablo II exe path.\n" + error_code_to_text(GetLastError())).c_str(), L"ERROR", MB_OK); string exename = path.substr(path.rfind("\\") + 1, path.size() - path.rfind("\\")); if (exename == "Game.exe") { if (!isInjected(hwnd)) { if (!InjectDll(hwnd)) { MessageBox(hwnd, L"Injection failed", L"ERROR", MB_OK); break; } } } } break; } } return TRUE; }