'CryptQueryObject' 未在此范围内声明
'CryptQueryObject' was not declared in this scope
#include <wincrypt.h>
已经添加了,为什么gcc-mingw32编译会报这个错呢?
'CryptQueryObject' was not declared in this scope
我正在研究 Window 10.
这是我的代码:
#include <iostream>
#include <wincrypt.h>
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
//#pragma comment(lib, "crypt32.lib")
#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
using namespace std;
int _tmain(int argc, TCHAR *argv[])
{
BOOL bIsSuccess;
DWORD dwEncoding, dwContentType, dwFormatType;
HCERTSTORE hStore = NULL;
HCRYPTMSG hMsg =NULL;
PVOID pvContext = NULL;
string szFileName;
szFileName ="C:\WINDOWS\System32\lsass.exe";
bIsSuccess = CryptQueryObject(CERT_QUERY_OBJECT_FILE,
szFileName,
CERT_QUERY_CONTENT_FLAG_ALL,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
&dwEncoding,
&dwContentType,
&dwFormatType,
&hStore,
&hMsg,
&pvContext);
- 在
windows.h
之后加上wincrypt.h
否则用Visual Studio编译也会报错。
- Link
crypt32.lib
像这样编译命令:
i686-w64-mingw32-g++ test.cpp -lcrypt32
编辑后的代码如下:
#include <iostream>
#include <windows.h>
#include <wincrypt.h>
#include <tchar.h>
#include <stdio.h>
//#pragma comment(lib, "crypt32.lib")
#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
using namespace std;
int _tmain(int argc, TCHAR* argv[])
{
BOOL bIsSuccess;
DWORD dwEncoding, dwContentType, dwFormatType;
HCERTSTORE hStore = NULL;
HCRYPTMSG hMsg = NULL;
PVOID pvContext = NULL;
string szFileName;
szFileName = "C:\WINDOWS\System32\lsass.exe";
bIsSuccess = CryptQueryObject(CERT_QUERY_OBJECT_FILE,
(const void*)szFileName.c_str(),
CERT_QUERY_CONTENT_FLAG_ALL,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
&dwEncoding,
&dwContentType,
&dwFormatType,
&hStore,
&hMsg,
(const void**)&pvContext);
}
#include <wincrypt.h>
已经添加了,为什么gcc-mingw32编译会报这个错呢?
'CryptQueryObject' was not declared in this scope
我正在研究 Window 10.
这是我的代码:
#include <iostream>
#include <wincrypt.h>
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
//#pragma comment(lib, "crypt32.lib")
#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
using namespace std;
int _tmain(int argc, TCHAR *argv[])
{
BOOL bIsSuccess;
DWORD dwEncoding, dwContentType, dwFormatType;
HCERTSTORE hStore = NULL;
HCRYPTMSG hMsg =NULL;
PVOID pvContext = NULL;
string szFileName;
szFileName ="C:\WINDOWS\System32\lsass.exe";
bIsSuccess = CryptQueryObject(CERT_QUERY_OBJECT_FILE,
szFileName,
CERT_QUERY_CONTENT_FLAG_ALL,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
&dwEncoding,
&dwContentType,
&dwFormatType,
&hStore,
&hMsg,
&pvContext);
- 在
windows.h
之后加上wincrypt.h
否则用Visual Studio编译也会报错。 - Link
crypt32.lib
像这样编译命令:
i686-w64-mingw32-g++ test.cpp -lcrypt32
编辑后的代码如下:
#include <iostream>
#include <windows.h>
#include <wincrypt.h>
#include <tchar.h>
#include <stdio.h>
//#pragma comment(lib, "crypt32.lib")
#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
using namespace std;
int _tmain(int argc, TCHAR* argv[])
{
BOOL bIsSuccess;
DWORD dwEncoding, dwContentType, dwFormatType;
HCERTSTORE hStore = NULL;
HCRYPTMSG hMsg = NULL;
PVOID pvContext = NULL;
string szFileName;
szFileName = "C:\WINDOWS\System32\lsass.exe";
bIsSuccess = CryptQueryObject(CERT_QUERY_OBJECT_FILE,
(const void*)szFileName.c_str(),
CERT_QUERY_CONTENT_FLAG_ALL,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
&dwEncoding,
&dwContentType,
&dwFormatType,
&hStore,
&hMsg,
(const void**)&pvContext);
}