Skip to content

Commit

Permalink
Mark the generated DLL with OLESelfRegister in the StringFileInfo (#67)
Browse files Browse the repository at this point in the history
The DLL provides the function DllRegisterServer for COM registration. To indicate that is has this method it should also include the value OLESelfRegister in the StringFileInfo
  • Loading branch information
vbaderks authored May 29, 2024
1 parent 806a20d commit e8e7fc3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/jpegls-wic-codec.rc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ BEGIN
VALUE "OriginalFilename", L"jpegls-wic-codec.dll"
VALUE "ProductName", L"JPEG-LS WIC codec"
VALUE "ProductVersion", VERSION
VALUE "OLESelfRegister", "\0"
END
END
BLOCK "VarFileInfo"
Expand Down
3 changes: 1 addition & 2 deletions src/jpegls_bitmap_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ struct jpegls_bitmap_encoder : implements<jpegls_bitmap_encoder, IWICBitmapEncod

// Note: the current implementation doesn't write metadata to the JPEG-LS stream.
// The SPIFF header can be used to store metadata items.
constexpr HRESULT result = wincodec::error_unsupported_operation;
return result;
return wincodec::error_unsupported_operation;
}

HRESULT __stdcall SetPalette(_In_ IWICPalette* palette) noexcept override
Expand Down
18 changes: 18 additions & 0 deletions test/dllmain_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import guids;
import util;
import winrt;
import "win.h";
import "std.h";

using namespace winrt;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
Expand Down Expand Up @@ -90,6 +91,23 @@ TEST_CLASS(dllmain_test)
Assert::AreEqual(error_no_aggregation, result);
}

TEST_METHOD(marked_for_self_registration) // NOLINT
{
const wchar_t dll_name[]{L"jpegls-wic-codec.dll"};
DWORD not_used;
const DWORD size{GetFileVersionInfoSizeEx(FILE_VER_GET_NEUTRAL, dll_name, &not_used)};
Assert::IsTrue(size != 0);

std::vector<std::byte> buffer(size);
bool result = GetFileVersionInfoEx(FILE_VER_GET_NEUTRAL, dll_name, 0, size, buffer.data());
Assert::IsTrue(result);

void* value;
UINT value_size;
result = VerQueryValue(buffer.data(), L"\\StringFileInfo\\000004b0\\OLESelfRegister", &value, &value_size);
Assert::IsTrue(result);
}

private:
factory factory_;
};

0 comments on commit e8e7fc3

Please sign in to comment.