ASP.NET MVC在Controller中,把JsonResult转为JSON字符串
string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(jsonResult.Data);
Response.Write(json);
ASP.NET MVC在Controller中,把JsonResult转为JSON字符串
string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(jsonResult.Data);
Response.Write(json);
使用System.IO.File.Create(path);创建的文件如何关闭
FileStream fs = System.IO.File.Create(path);
fs.Close();
使用下面的命令查看Hello.exe
所依赖的DLL:
windeployqt Hello.exe
如果还有缺少的DLL,可以根据报错提示用 Everything 工具进行查找,然后放进程序目录就行了。
qt quick 的程序要这样发布
-qmldir 后面是qt的qml目录
windeployqt daolan.exe -qmldir "D:\Qt\Qt5.8.0\5.8\mingw53_32\qml"
一个 VC++ 中使用的 HttpClient 类,可以进行HTTP GET和POST,代码如下:
HttpClient.h
#pragma once
#include <string>
#include <vector>
using namespace std;
class CHttpClient
{
public:
CHttpClient(void);
~CHttpClient(void);
BOOL Get(LPCSTR url, string &result);
};
HttpClient.cpp
#include "stdafx.h"
#include "HttpClient.h"
#include <wininet.h>
#pragma comment(lib, "wininet.lib")
CHttpClient::CHttpClient(void)
{
}
CHttpClient::~CHttpClient(void)
{
}
BOOL CHttpClient::Get(LPCSTR url, string &result)
{
result.clear();
vector<char> v;
const CHAR * szUrl = url;
CHAR szAgent[] = "";
HINTERNET hInternet1 =
InternetOpen(NULL,INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,NULL);
if (NULL == hInternet1)
{
InternetCloseHandle(hInternet1);
return FALSE;
}
HINTERNET hInternet2 =
InternetOpenUrl(hInternet1,szUrl,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE,NULL);
if (NULL == hInternet2)
{
InternetCloseHandle(hInternet2);
InternetCloseHandle(hInternet1);
return FALSE;
}
DWORD dwMaxDataLength = 500;
PBYTE pBuf = (PBYTE)malloc(dwMaxDataLength*sizeof(TCHAR));
if (NULL == pBuf)
{
InternetCloseHandle(hInternet2);
InternetCloseHandle(hInternet1);
return FALSE;
}
DWORD dwReadDataLength = NULL;
BOOL bRet = TRUE;
do
{
ZeroMemory(pBuf,dwMaxDataLength*sizeof(TCHAR));
bRet = InternetReadFile(hInternet2,pBuf,dwMaxDataLength,&dwReadDataLength);
for (DWORD dw = 0;dw < dwReadDataLength;dw++)
{
v.push_back(pBuf[dw]);
}
} while (NULL != dwReadDataLength);
vector<char>::iterator i;
for(i=v.begin(); i!=v.end(); i++)
result += *i;
return TRUE;
}
ProcessStartInfo 一定要写全路径,不然会出现一些莫明其妙的错误,比如开机自动启动时打不开。
ProcessStartInfo p1 = new ProcessStartInfo($"{Application.StartupPath}\\PD101AHelper.exe", $"{address} \"{windowShowMsg.Trim()}\" \"{zhShowMsg2 ?? ""}\"");
p1.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(p1);