发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
#include "sky_file.h"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <ios>
#include <windows.h>
using namespace std;
int SkyReadFileA(char ** chr)
{
string file_path="";
char buf[1000];
int i=1000;
GetCurrentDirectory(1000,buf); //得到当前工作路径
string path1(buf);
path1=path1 + "\\txt.txt";
file_path= path1 ;
file_path="H:\\工具软件\\开发工具\\ASP.DLL防止反编译\\Test\\CImportDemo\\WebApplication1\\txt.txt";
cout<<path1<<endl;
//定义一个输入流
ifstream input;
string data_in_file3;
vector<string> data_file;
string dataAll;
dataAll="";
int iReturn;
iReturn=0;
input.open(file_path);
if(!input)
{
cout<<"Can't open file to input."<<endl;
iReturn=1;
memcpy(*chr,file_path.c_str(),file_path.length());
return iReturn;
}
while (!input.eof())
{
getline(input,data_in_file3);
//cout<<data_in_file3<<endl;
dataAll+= data_in_file3;
data_file.push_back(data_in_file3);
}
int n=1;
cout<<dataAll<<endl;
/*for (vector<string>::iterator i=data_file.begin();i<=data_file.cend;++i)
{
cout<<n<<*i<<endl;
++n;
dataAll+=*i;
}*/
//chr= & dataAll;
memcpy(*chr,dataAll.c_str(),dataAll.length());
//chr = dataAll.c_str();
return iReturn;
}
int SkyReadFile( char chr )
{
int iReturn;
iReturn=0;
/*ofstream fout;
fout.open("output.txt");
if(!fout)
{
cout<<"Can't open file to output"<<endl;
iReturn=1;
return iReturn;
}*/
ifstream fin("test.txt");
if(!fin)
{
cout<<"Can't open file to input."<<endl;
iReturn=1;
return iReturn;
}
return iReturn;
}
extern "C" __declspec( dllexport ) int SkyReadFileB(char** s2 )
{
return SkyReadFileA(s2);
}
public static extern int Multiplication(int a, int b, ref int c);
[DllImport("CDllProject.dll",
EntryPoint = "SkyReadFileB",
CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl
)]
public static extern int SkyReadFileB(ref StringBuilder s);
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。