char dllname[_MAX_PATH] = {0};::GetModuleFileName( NULL, (LPWSTR)dllname, sizeof(dllname) );QString qstr=dllname;qDebug()<<qstr;
::GetModuleFileName( (HMODULE)this->winId(), (LPWSTR)dllname, sizeof(dllname) );
static HMODULE GetThisDllHandle(){ MEMORY_BASIC_INFORMATION info; size_t len = VirtualQueryEx(GetCurrentProcess(), (void*)GetThisDllHandle, &info, sizeof(info)); assert(len == sizeof(info)); return len ? (HMODULE)info.AllocationBase : NULL;}
C++ (Qt) typedef QString (*Func)(const char *, int); Func func = &QString::fromLocal8Bit; HMODULE hmodule = 0; bool ok = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, LPCTSTR(func), &hmodule); if (ok && hmodule) { ushort path[MAX_PATH] = { 0 }; ok = GetModuleFileName(hmodule, path, MAX_PATH - 1); QString fullName = QString::fromUtf16(path); qDebug() << "ok =" << ok << "path =" << fullName; }