#endif
}
+#ifdef OS_WINDOWS
+void change_working_directory(void)
+{
+ TCHAR currentDir[MAX_PATH] = {0,};
+ TCHAR modulePath[MAX_PATH] = {0,};
+ DWORD dwRet = 0;
+ char* p = NULL;
+
+ dwRet = GetCurrentDirectory(MAX_PATH, currentDir);
+ if (dwRet == 0) {
+ LOG_INFO("GetCurrentDirectory failed (%d)\n", GetLastError());
+ return;
+ }
+ if (dwRet > MAX_PATH) {
+ LOG_INFO("Buffer too small; need %d charactors\n", dwRet);
+ return;
+ }
+ LOG_INFO("Current directory : %s\n", currentDir);
+
+ if (!GetModuleFileName(NULL, modulePath, sizeof(modulePath))) {
+ LOG_INFO("GetModuleFileName failed (%d)\n", GetLastError());
+ return;
+ }
+ LOG_INFO("Module path : %s\n", modulePath);
+
+ p = strrchr(modulePath, '\\');
+ if (p) {
+ p[1] = '\0';
+ }
+
+ if (!SetCurrentDirectory(modulePath)) {
+ LOG_INFO("SetCurrentDirectory failed (%d)\n", GetLastError());
+ return;
+ }
+ LOG_INFO("Set current directory to : %s\n", modulePath);
+}
+#endif
int sdb_main(int is_daemon, int server_port)
{
sdb_usb_init();
#ifdef OS_WINDOWS
+ change_working_directory();
+
sdb_thread_t thr;
void* (*func)(void *);
func = local_init_thread;