- 积分
- 36104
- 明经币
- 个
- 注册时间
- 2013-8-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2023-10-28 21:22:24
|
显示全部楼层
本帖最后由 baitang36 于 2023-10-28 21:24 编辑
和下面这个有区别吗?定义lisp函数获取登录的QQ号 - AutoCAD.net/VB.net/C# 编程技术 - AutoCAD论坛 - 明经CAD社区 - Powered by Discuz! (mjtd.com)
//导入库 [DllImport("user32.dll")]
[DllImport("user32.dll", EntryPoint = "FindWindowA", CharSet = CharSet.Ansi)]
private static extern int FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "GetWindowText")]
public static extern int GetWindowText(int hwnd, StringBuilder lpString, int cch);
[DllImport("user32.dll", EntryPoint = "GetWindow")]
public static extern int GetWindow(int hwnd, int wCmd);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int GetClassName(int hWnd, StringBuilder lpClassName, int nMaxCount);
[LispFunction("ReadTencentqqId")]
public static string ReadTencentqqId(ResultBuffer rb)
{
string str = "";
int hWin = FindWindow("CTXOPConntion_Class", null);
if (hWin == 0)
{
return null;
}
System.Text.StringBuilder sbf = new StringBuilder(256);
StringBuilder sbfClass = new StringBuilder(256);
while (hWin > 0)
{
GetWindowText(hWin, sbf, sbf.Capacity);
if (sbf.ToString().Contains("OP_"))
{
int index = sbf.ToString().IndexOf('_');
str = sbf.ToString().Substring(index + 1, sbf.Length - index - 1);
break;
}
}
return str;
} |
|