1
我真的寫VB.net,需要調用API(C語言DLL)如何轉換C代碼的fread到VB.NET
我的測試示例代碼如下
//Read Source File
char *SourceFilePath = "C:\\Docs\\Scandi\\attach\\verifyTest\\center.xml";
FILE *sourcefile= fopen(SourceFilePath, "rb");
if (!sourcefile)
{
printf("Error=%s\n", *SourceFilePath);
return;
}
fseek(sourcefile,0,SEEK_END);
long src_ch_len = ftell(sourcefile);
rewind(sourcefile);
unsigned char *src_ch =(unsigned char*)malloc(sizeof(char)*src_ch_len);
result = fread(src_ch,1,src_ch_len,sourcefile);
if(result!=src_ch_len)
{
printf("Reading Error=%s\n", *sourcefile);
return;
}
fclose(sourcefile);
//Read Data File
//Skip...
rc = BasicVerify(algorithm, data, dataLen, key, signature, signatureLen);
API函數定義
unsigned long verify(unsigned long algorithm, unsigned char *data, int dataLen,unsigned char *signature, int signatureLen, char *cerFile)
如何給fopen(SourceFilePath, 「RB」)和FREAD(src_ch,1,src_ch_len,的資源文件)轉換爲VB.NET
謝謝
[File.ReadAllText(https://msdn.microsoft.com/en-us/library/ms143368(V = VS。 110).aspx?cs-save-lang = 1&cs-lang = vb#code-snippet-1),[StreamReader.ReadToEnd](https://msdn.microsoft.com/zh-cn/library/system.io。 streamreader.readtoend(v = vs.110).ASPX?CS-保存琅= 1&CS琅= VB#代碼片斷-1) – BLUEPIXY