Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

Commit e892f9f

Browse files
committed
Fixed logging
1 parent bf16b59 commit e892f9f

5 files changed

Lines changed: 46 additions & 19 deletions

File tree

Core/Log.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Log::Log()
2222
filename = CreateFileName();
2323
file.Open(filename, wxFile::OpenMode::write_append);
2424

25+
AddLine("=============================================");
26+
2527
// Report voukoder version
2628
AddLine(wxString::Format("Voukoder %d.%d.%d",
2729
VKDR_VERSION_MAJOR,

Installer/Installer.wixproj

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,13 @@
22
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
5+
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
66
<ProductVersion>3.10</ProductVersion>
77
<ProjectGuid>28f27aff-4920-4de6-9000-1be251c85c1f</ProjectGuid>
88
<SchemaVersion>2.0</SchemaVersion>
99
<OutputName>voukodercore</OutputName>
1010
<OutputType>Package</OutputType>
1111
</PropertyGroup>
12-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
13-
<OutputPath>bin\$(Configuration)\</OutputPath>
14-
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
15-
<DefineConstants>Debug</DefineConstants>
16-
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
18-
<OutputPath>bin\$(Configuration)\</OutputPath>
19-
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
20-
</PropertyGroup>
2112
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
2213
<DefineConstants>Debug</DefineConstants>
2314
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>

Voukoder.sln

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ Global
5151
{8603D9F4-BC08-4FB2-BB81-04A7583D222C}.Release|x64.ActiveCfg = Release|x64
5252
{8603D9F4-BC08-4FB2-BB81-04A7583D222C}.Release|x64.Build.0 = Release|x64
5353
{8603D9F4-BC08-4FB2-BB81-04A7583D222C}.Release|x86.ActiveCfg = Release|x64
54-
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Debug|x64.ActiveCfg = Debug|x86
55-
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Debug|x86.ActiveCfg = Debug|x86
56-
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Debug|x86.Build.0 = Debug|x86
54+
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Debug|x64.ActiveCfg = Debug|x64
55+
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Debug|x64.Build.0 = Debug|x64
56+
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Debug|x86.ActiveCfg = Debug|x64
5757
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Release|x64.ActiveCfg = Release|x64
5858
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Release|x64.Build.0 = Release|x64
59-
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Release|x86.ActiveCfg = Release|x86
60-
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Release|x86.Build.0 = Release|x86
59+
{28F27AFF-4920-4DE6-9000-1BE251C85C1F}.Release|x86.ActiveCfg = Release|x64
6160
{3FECB18E-1792-4D81-9BC5-5E546CC775CD}.Debug|x64.ActiveCfg = Debug|x64
6261
{3FECB18E-1792-4D81-9BC5-5E546CC775CD}.Debug|x64.Build.0 = Debug|x64
6362
{3FECB18E-1792-4D81-9BC5-5E546CC775CD}.Debug|x86.ActiveCfg = Debug|Win32

Voukoder/CVoukoder.cpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@ static inline void AvCallback(void*, int level, const char* szFmt, va_list varg)
1212
}
1313
#endif
1414

15+
struct handle_data {
16+
unsigned long process_id;
17+
HWND window_handle;
18+
};
19+
20+
BOOL IsMainWindow(HWND handle)
21+
{
22+
return GetWindow(handle, GW_OWNER) == (HWND)0 && IsWindowVisible(handle);
23+
}
24+
25+
BOOL CALLBACK EnumWindowsCallback(HWND handle, LPARAM lParam)
26+
{
27+
handle_data& data = *(handle_data*)lParam;
28+
unsigned long process_id = 0;
29+
GetWindowThreadProcessId(handle, &process_id);
30+
if (data.process_id != process_id || !IsMainWindow(handle))
31+
return TRUE;
32+
data.window_handle = handle;
33+
return FALSE;
34+
}
35+
36+
HWND FindMainWindow(unsigned long process_id)
37+
{
38+
handle_data data;
39+
data.process_id = process_id;
40+
data.window_handle = 0;
41+
EnumWindows(EnumWindowsCallback, (LPARAM)&data);
42+
return data.window_handle;
43+
}
44+
1545
class actctx_activator
1646
{
1747
protected:
@@ -39,9 +69,14 @@ CVoukoder::CVoukoder():
3969
av_log_set_callback(AvCallback);
4070
#endif
4171

42-
wchar_t wnd_title[256];
43-
HWND hwnd = GetForegroundWindow(); // get handle of currently active window
44-
GetWindowText(hwnd, wnd_title, sizeof(wnd_title));
72+
// Add window title to log
73+
wchar_t text[256];
74+
HWND hwnd = FindMainWindow(GetCurrentProcessId());
75+
if (GetWindowText(hwnd, text, sizeof(text)))
76+
{
77+
vkLogInfo(wxString::Format("Plugin running in %s", text));
78+
vkLogInfo("---------------------------------------------");
79+
}
4580
}
4681

4782
CVoukoder::~CVoukoder()

Voukoder/Registrar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class CDllRegistrar : public CRegistrar
126126

127127
swprintf_s(Buffer, L"CLSID\\%s\\InProcServer32", strCLSID);
128128

129-
if (!SetInRegistry(HKEY_CLASSES_ROOT, Buffer, L"ThreadingModel", L"Both"))
129+
if (!SetInRegistry(HKEY_CLASSES_ROOT, Buffer, L"ThreadingModel", L"Apartment"))
130130
return false;
131131

132132
return SetInRegistry(HKEY_CLASSES_ROOT, Buffer, L"", Path) ? true : false;

0 commit comments

Comments
 (0)