110,538
社区成员
发帖
与我相关
我的任务
分享
int Login([in]const char* lpszAccount, [in]const char* lpszPassword, [in][out]TChar* lpszMessage, [in][out]int* lpszMessageBufferSize);
[System.Runtime.InteropServices.DllImport("Login.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
public static extern int Login(byte[] account, byte[] password, StringBuilder message, ref int bufferSize);
public static int LoginMeIn(string account, string password, out message)
{
int bufferSize = 1024;
StringBuilder sb = new StringBuilder(bufferSize);
int result = Login(
System.Text.Encoding.Default.GetBytes(account),
System.Text.Encoding.Default.GetBytes(password),
sb,
ref bufferSize);
message = sb.ToString();
return result;
问题一:请问这里用到的byte[]数组以及StringBuilder都需要手动释放吗?
}
int Login([in]const char* lpszAccount, [in]const char* lpszPassword,
[in][out]TChar* lpszMessage, [in][out]int* lpszMessageBufferSize);
[System.Runtime.InteropServices.DllImport("Login.dll",
CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
public static extern int Login(byte[] account, byte[] password,
StringBuilder message, ref int bufferSize);
public static int LoginMeIn(string account, string password, out message)
{
int bufferSize = 1024;
StringBuilder sb = new StringBuilder(bufferSize);
int result = Login(
System.Text.Encoding.Default.GetBytes(account),
System.Text.Encoding.Default.GetBytes(password),
sb,
ref bufferSize);
message = sb.ToString();
return result;
}