Using dfshim.dll to control ClickOnce applications in unmanaged C++

I just found out that there is a minimal unmanaged API for ClickOnce applications in windows that is located in dfshim.dll. Unfortunately I could only find a very incomplete documentation on MSDN:

There are only very few references in the web. All of them are using the DLL by executing command lines to call the DLL's functions using rundll32.exe.

I would like to call the DLL's functions from C++ code. I did not find a header file to include or a stub-file to link.

I could explicitely load the DLL during runtime and resolve the function symbols manually but that seems pretty uncommon for a Windows API. Also I would need to guess the signature for many of the functions.

How can I use that DLL with Visual Studio 2013? Why is there no include file? Is this actually an official/public API?

1 Answer

Strange, this code is hardly documented.

we ended up in this code:

bool LaunchClickOnceApplication(LPCSTR pszApplication)
{
HRESULT hr(-1);
HINSTANCE hInst = ::LoadLibrary("dfshim.dll");
if ( hInst )
{ typedef HRESULT (WINAPI *dfshim_LaunchApplicationProc) (LPCWSTR pszApplication, LPVOID pData, DWORD dwFlags); dfshim_LaunchApplicationProc fnLaunch = (dfshim_LaunchApplicationProc)GetProcAddress(hInst, "LaunchApplication"); if ( fnLaunch ) { hr = fnLaunch(CA2W(pszApplication), NULL, 0); } ::FreeLibrary(hInst); return SUCCEEDED(hr);
}
else
{ DWORD dwErr = ::GetLastError(); char szMsg[128]; _snprintf_s(szMsg, sizeof(szMsg), _TRUNCATE, "Cannot load dfshim.dll: %lu", dwErr); AfxMessageBox(szMsg); return false;
}
}

It is kind of unprofessional not to rely on documentation. It it more like a hack, but I don't see an alternative way. This code works for us.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like