大家好,小弟目前在修改VC程序(其实是VS2010中VC#程序),在一个VC的class中调用另一个class中的函数,发觉无法调用。我写的函数如下(是一个读初始文件的函数)
------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices; //可以调用 kernel32 API了
namespace CallDll
{
class ReadFile
{
public string m_file_path;
[DllImport("kernel32 ")]
private static extern long WritePrivateProfileString(string Section, string Key, string Val, string FilePath);
[DllImport("kernel32 ")]
private static extern int GetPrivateProfileString(string Section, string Key, string Def, StringBuilder RetVal, int Size, string FilePath);
public ReadFile(string IniFilePath)
{
m_file_path = IniFilePath;
}
public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, m_file_path);
}
public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, " ", temp, 255, m_file_path);
return temp.ToString();
}
//读取函数,也就是要调用的函数
public string readinifile(string mPathfle, string mSection, string mKey)
{
ReadFile ini = new ReadFile(mPathfle);
return ini.IniReadValue(mSection, mKey);
}
internal static string readinifile()
{
throw new NotImplementedException();
}
}
}
-----------------------------------------------
目前是,我要在另一个class( public partial class MainForm : Form中)中调用函数readinifile
求大家帮忙了
以前有使用VB编程,感觉差异太大,
------解决方案--------------------------------------------------------
public string readinifile(string mPathfle, string mSection, string mKey)