3 void registerclass_scope_delayed::toggle_on(UINT p_style,WNDPROC p_wndproc,
int p_clsextra,
int p_wndextra,HICON p_icon,HCURSOR p_cursor,HBRUSH p_background,
const TCHAR * p_class_name,
const TCHAR * p_menu_name) {
7 wc.lpfnWndProc = p_wndproc;
8 wc.cbClsExtra = p_clsextra;
9 wc.cbWndExtra = p_wndextra;
12 wc.hCursor = p_cursor;
13 wc.hbrBackground = p_background;
14 wc.lpszMenuName = p_menu_name;
15 wc.lpszClassName = p_class_name;
16 WIN32_OP_CRITICAL(
"RegisterClass", (
m_class = RegisterClass(&wc)) != 0);
29 unsigned ret = GetDeviceCaps(dc,LOGPIXELSY);
37 SIZE ret = { GetDeviceCaps(dc,LOGPIXELSY), GetDeviceCaps(dc,LOGPIXELSY) };
44 unsigned n,m=GetMenuItemCount(menu);
46 if (GetSubMenu(menu,n))
return true;
47 if (!(GetMenuState(menu,n,MF_BYPOSITION)&MF_SEPARATOR))
return true;
53 const DWORD code = GetLastError();
54 PFC_ASSERT( code != NO_ERROR );
59 const DWORD code = GetLastError();
60 PFC_ASSERT( code != NO_ERROR );
66 void WIN32_OP_D_FAIL(
const wchar_t * _Message,
const wchar_t *_File,
unsigned _Line) {
67 const DWORD code = GetLastError();
69 wsprintfW(msgFormatted.
get_ptr(), L
"%s (code: %u)", _Message, code);
70 if (IsDebuggerPresent()) {
71 OutputDebugString(TEXT(
"WIN32_OP_D() failure:\n"));
72 OutputDebugString(msgFormatted.
get_ptr());
73 OutputDebugString(TEXT(
"\n"));
76 _wassert(msgFormatted.
get_ptr(),_File,_Line);
86 HMODULE module = GetModuleHandle(_T(
"ntdll.dll"));
87 if (!module)
return false;
88 return GetProcAddress(module,
"wine_server_call") != NULL;
91 typedef const char *(__cdecl *t_wine_get_build_id)(
void);
92 typedef void (__cdecl *t_wine_get_host_version)(
const char **sysname,
const char **release );
93 const HMODULE ntdll = GetModuleHandle(_T(
"ntdll.dll"));
94 if (ntdll == NULL)
return false;
95 t_wine_get_build_id wine_get_build_id;
96 t_wine_get_host_version wine_get_host_version;
97 wine_get_build_id = (t_wine_get_build_id)GetProcAddress(ntdll,
"wine_get_build_id");
98 wine_get_host_version = (t_wine_get_host_version)GetProcAddress(ntdll,
"wine_get_host_version");
99 if (wine_get_build_id == NULL || wine_get_host_version == NULL) {
100 if (GetProcAddress(ntdll,
"wine_server_call") != NULL) {
101 out <<
"wine (unknown version)";
106 const char * sysname = NULL;
const char * release = NULL;
107 wine_get_host_version(&sysname, &release);
108 out << wine_get_build_id() <<
", on: " << sysname <<
" / " << release;
115 OSVERSIONINFO ver = {}; ver.dwOSVersionInfoSize =
sizeof(ver);
116 WIN32_OP( GetVersionEx(&ver) );
117 SYSTEM_INFO
info = {};
118 GetNativeSystemInfo(&info);
120 out <<
"Windows " << (int)ver.dwMajorVersion <<
"." << (
int)ver.dwMinorVersion <<
"." << (int)ver.dwBuildNumber;
123 switch(info.wProcessorArchitecture) {
124 case PROCESSOR_ARCHITECTURE_AMD64:
125 out <<
" x64";
break;
126 case PROCESSOR_ARCHITECTURE_IA64:
127 out <<
" IA64";
break;
128 case PROCESSOR_ARCHITECTURE_INTEL:
129 out <<
" x86";
break;
136 info.fMask = MIIM_STATE;
137 GetMenuItemInfo(p_menu,p_id,FALSE,&info);
138 info.fState |= MFS_DEFAULT;
139 SetMenuItemInfo(p_menu,p_id,FALSE,&info);
145 if (OpenClipboard(NULL)) {
147 HANDLE handle = GlobalAlloc(GMEM_MOVEABLE,p_block_size);
148 if (handle == NULL) {
150 throw std::bad_alloc();
153 if (SetClipboardData(p_format,handle) == NULL) {
168 case WAIT_OBJECT_0+1:
169 throw exception_aborted();
182 if (inPath != NULL) {
198 if (inReader.is_empty()) {
203 file::ptr writer =
fileOpenWriteNew( PFC_string_formatter() <<
"file://" << tempPath, aborter, 1.0 );
204 file::g_transfer_file( inReader , writer, aborter );
208 if (m_isTemp && m_path.length() > 0) {
212 if (DeleteFile( m_path.c_str() ))
break;
213 if (timer.
query() > 1.0)
break;
221 WIN32_OP_CRITICAL(
"CreateMutex", m_hMutex = CreateMutex(NULL, FALSE, name) );
224 CloseHandle(m_hMutex);
235 case WAIT_OBJECT_0 + 1:
236 PFC_ASSERT( aborter.is_aborting() );
237 throw exception_aborted();
244 AcquireByHandle( Handle(), aborter );
248 ReleaseMutex( Handle() );
254 const unsigned div = 4;
255 for(
unsigned walk = 0; walk < div; ++walk) {
bool SetClipboardDataBlock(UINT p_format, const void *p_block, t_size p_block_size)
DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds)
unsigned QueryScreenDPI()
const t_item * get_ptr() const
PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL()
void SetDefaultMenuItem(HMENU p_menu, unsigned p_id)
bool IsMenuNonEmpty(HMENU menu)
void toggle_on(UINT p_style, WNDPROC p_wndproc, int p_clsextra, int p_wndextra, HICON p_icon, HCURSOR p_cursor, HBRUSH p_background, const TCHAR *p_classname, const TCHAR *p_menuname)
static bool running_under_wine(void)
void info(const char *p_message)
void GetOSVersionString(pfc::string_base &out)
bool _extract_native_path_ptr(const char *&p_fspath)
void GetOSVersionStringAppend(pfc::string_base &out)
string_wide_from_utf8_t string_wide_from_utf8
void winPrefixPath(pfc::string_base &out, const char *p_path)
void WIN32_OP_D_FAIL(const wchar_t *_Message, const wchar_t *_File, unsigned _Line)
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
file_ptr fileOpenWriteNew(const char *p_path, abort_callback &p_abort, double p_timeout=0)
string_utf8_from_wide string_utf8_from_os
const char * get_ptr() const
DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
CMutex(const TCHAR *name=NULL)
t_size strlen_t(const t_char *p_string, t_size p_length=~0)
void set_size(t_size p_size)
void open(const char *inPath, file::ptr inReader, abort_callback &aborter)
static void AcquireByHandle(HANDLE hMutex, abort_callback &aborter)
mutexScope(HANDLE hMutex_, abort_callback &abort)
PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL_CRITICAL(const char *what)
file_ptr fileOpenReadExisting(const char *p_path, abort_callback &p_abort, double p_timeout=0)
static bool FetchWineInfoAppend(pfc::string_base &out)
HINSTANCE get_my_instance()
Retrieves HINSTANCE of calling DLL.
void Acquire(abort_callback &aborter)
PFC_NORETURN void SHARED_EXPORT uBugCheck()
BOOL SHARED_EXPORT uGetTempPath(pfc::string_base &out)
CMutexScope(CMutex &mutex, DWORD timeOutMS, const char *timeOutBugMsg)
void add_filename(const char *fn)