|zyciis| 一个.NET工商银行B2C查询示例 我是用C#的 看不懂他的这是哪个语言 如何译成C#的 谢谢

zyciis164 zyciis164 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

#include "stdafx.h"

#include <windows.h>
#include <wininet.h>
#include <stdio.h>

void main(int argc, _TCHAR *argv[])
{
if(argc<3) {
printf("USAGE: %s [webserver] [username]\n", argv[0]);
return;
}

// Open the internet connection
HINTERNET hInternetSession = InternetOpen(
"Wininet Client App", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0) ;
HINTERNET hInternetConnect = InternetConnect(hInternetSession, argv[1],
INTERNET_DEFAULT_HTTPS_PORT, "", "", INTERNET_SERVICE_HTTP, 0, 0);
HINTERNET hHttpOpenRequest = HttpOpenRequest(hInternetConnect, "GET", "",
HTTP_VERSION, "", NULL,
INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD | INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_IGNORE_CERT_CN_INVALID | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID, 0);

BOOL bRet;
DWORD dwLastError = 0;

// Send the HTTP request
bRet = HttpSendRequest(hHttpOpenRequest, NULL, 0, 0, 0);
if (!bRet) dwLastError = GetLastError();

// Get the certificate information from the server if available.
INTERNET_CERTIFICATE_INFO sInfo;
DWORD length = sizeof(sInfo);
InternetQueryOption(hHttpOpenRequest, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT,
(LPVOID)&sInfo, &length);
printf("The Issuer of the server certificate is:\n%s\n", sInfo.lpszIssuerInfo );
printf("The Subject of the server certificate is:\n%s\n", sInfo.lpszSubjectInfo );

// Look up the local certicate store to get a certificate that matches the one of the server.
PCCERT_CONTEXT pCertContext = NULL;
HCERTSTORE hCertStore = CertOpenSystemStore(NULL, "MY");
char pszIssuer[256] = "\0";
char pszSubject[256] = "\0";
BOOL bGotCert = FALSE;

while(pCertContext = CertEnumCertificatesInStore(hCertStore,pCertContext))
{
printf("The following certificates are available:\n");
CertGetNameString(pCertContext,CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL,
pszIssuer, 256);
printf("Issuer: %s\n", pszIssuer);
CertGetNameString(pCertContext,CERT_NAME_SIMPLE_DISPLAY_TYPE,0,NULL,
pszSubject, 256);
printf("Subject: %s\n", pszSubject);
if ((strcmp(pszSubject, argv[2]) == 0) && (strcmp(pszIssuer, sInfo.lpszIssuerInfo) == 0)) {
bGotCert = TRUE;
printf("\nFound a certificate that matches the web server certificate.\n");
break;
}
}

// If the web server requires a cert and we found a matching one, attach the cert to the request.
if (( dwLastError == ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED ) && bGotCert)
{
printf("Sending a HTTP request to the web server with the found certificate...\n");
if (InternetSetOption(hHttpOpenRequest, INTERNET_OPTION_CLIENT_CERT_CONTEXT,
(void*)pCertContext, sizeof(*pCertContext)) )
{
CertDuplicateCertificateContext(pCertContext);
}
}

bRet = HttpSendRequest(hHttpOpenRequest, NULL, 0, 0, 0);

if (bRet) {
DWORD dwCode, dwSize;
dwSize = sizeof(dwCode);
if ( !HttpQueryInfo (hHttpOpenRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL))
{
}

if (dwCode == 200)
printf("Request sent to the server successfully.(HTTP Status: %d)\n", dwCode);
if (dwCode == 403)
printf("You didn't select a valid certificate. (HTTP Status: %d)\n", dwCode);
} else {
printf("Untrusted CA.\n");
}

CertFreeCertificateContext(pCertContext);
CertCloseStore(hCertStore,0);

InternetCloseHandle (hInternetSession);
InternetCloseHandle (hInternetConnect);
InternetCloseHandle (hHttpOpenRequest);

printf("Press any key to continue...");
getchar();
}


谢谢
...全文

相关推荐

全面掌握B2C购物网站系统开发:C#实践指南

C#(发音为 "看井")是一种由微软开发的面向对象的编程语言,是.NET框架的一部分。它以其清晰的语法、强大的类型系统和对现代编程范式的支持而闻名。C#提供了一种简洁、安全和现代的方法来构建各种类型的应用程序,从传统的Windows桌面应用程序到现代的云计算服务。

八位数花园

【多无人机协同目标运输任务】多无人机协同目标运输任务中的路径规划与动态控制研究(Matlab代码实现) ​

内容概要:本文聚焦于多无人机协同执行目标运输任务中的关键问题,系统研究了复杂环境下多无人机系统的路径规划与动态控制策略,并提供了基于Matlab的完整仿真代码实现。研究内容包括多智能体协同机制设计、高效路径规划算法(如改进RRT*、A*等)的应用、动态响应控制策略(如反步控制、滑模控制等)的集成,以及任务过程中无人机间的协调控制逻辑。通过高保真度仿真验证了所提方法在不同场景下的有效性、鲁棒性与实用性,代码配备详尽注释,便于理解与二次开发。; 适合人群:具备一定控制理论基础和Matlab编程能力,从事无人机控制、多智能体系统、智能交通或机器人协同等方向的科研人员及研究生(工作1-3年或研一以上水平);; 使用场景及目标:①用于多无人机协同运输任务的算法设计与仿真验证;②支撑科研论文复现、课题开发及工程原型构建;③深入理解路径规划与动态控制在多机协同中的耦合关系与实现方式;; 阅读建议:建议结合Matlab代码逐模块调试运行,配合控制理论教材深化对控制律设计的理解;建议先掌握单无人机基本控制原理,再逐步过渡到多机协同逻辑的学习,以提升整体系统认知与实践效率。

涛哥依旧_yyds

RustFs文件同步中的rc命令所使用得到

RustFs文件同步中的rc命令所使用得到

会说法语的猪

EPLAN中采用多重复制快速画图的方法演示

EPLAN中采用多重复制快速画图的方法演示

AAA_自控运维

Delphi D7Studio-1.2.1.0-setup.rar

Delphi D7Studio-1.2.1.0-setup.rar

tjsoft
评论 7
收藏 已收藏
分享
返回顶部
zyciis164
.NET社区 62,275 成员 668,967 内容