110,537
社区成员
发帖
与我相关
我的任务
分享
BOOL GetPrivateProfileStruct(
LPCTSTR lpszSection,
LPCTSTR lpszKey,
LPVOID lpStruct,
UINT uSizeStruct,
LPCTSTR szFile
);
[DllImport("kernel32.dll")]
public static extern long GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int Size, string filePath);
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication48
{
unsafe public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
char** Names = (char**)Marshal.AllocHGlobal(10000);
Names[0] = (char*)Marshal.UnsafeAddrOfPinnedArrayElement("小李".ToCharArray(), 0);
Names[1] = (char*)Marshal.UnsafeAddrOfPinnedArrayElement("小王".ToCharArray(), 0);
Names[2] = (char*)Marshal.UnsafeAddrOfPinnedArrayElement("小张".ToCharArray(), 0);
char* p = Names[0];
ShowName(p);
p += Names[1] - Names[0];
ShowName(p);
p += Names[2] - Names[1];
ShowName(p);
}
void ShowName(char* p)
{
MessageBox.Show(Marshal.PtrToStringAuto(new IntPtr(p)));
}
}
}