I'm trying to compile a simple C++ program that uses some functions and datastructures from the Win32 API and Wincrypt:
#include <memory>
using std::unique_ptr;
#include <Windows.h>
#include <Wincrypt.h>
using CERTSTORE_ptr = unique_ptr<CERTSTORE, decltype(&:: CertCloseStore)>;
int main(int argc, char* argv[])
{
return 0;
}
When I attempt to compile it, I get errors at the using CERTSTORE_ptr ...
line. The errors:
test.cpp(18): error C2873: 'CERTSTORE_ptr' : symbol cannot be used in a using-declaration
test\certstoreexporttest.cpp(18): error C2513: 'int' : no variable declared before '='
test\certstoreexporttest.cpp(18): error C2065: 'CERTSTORE' : undeclared identifier
...
The problem appears to be with CERTSTORE
and HCERTSTORE
, which is typedef'd as:
typedef void *HCERTSTORE;
How do I declare the using statement so I can enjoy the automatic cleanup? (I'm trying to avoid the __try\__finally
).
Or is this simply the wrong approach and should be abandoned? (I'm ready to go back to __try\__finally
so I can finish up this test program).