• 大小: 6KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-06-16
  • 语言: C#
  • 标签: KIS专业版  

资源简介

C#调用金蝶登录窗口(专业版12.2以后也可以),非专业代码,也非专业程序员!

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace cndrgj
{
    class KingdeeLogin
    {
        public Boolean KISLogin()
        {

            try
            {
                //ps:K3或者KIS调用登录窗口,其中有K3Login.dll的直接调用,KISLogin的:KIS专业版12.2以前的直接调用,12.2以后的直接调用不行
                //然后我就在网上找到了vb调用12.2以后的方法,需要执行一个SetDate方法,
                //我不知道C#怎么写这个方法,就直接把VB的这个SetDate方法生成dll,然后在C#里调用这个DLL就可以了
                //下面是VB方法:
                //Private Declare Function GetDesktopWindow Lib “user32“ () As Long
                //Private Declare Function SetProp Lib “user32“ Alias “SetPropA“ (ByVal hwnd As Long ByVal lpString As String ByVal hData As Long) As Long
                //Private Declare Function GetCurrentProcessId Lib “kernel32“ () As Long
                //Private m_dctGlobalInfo As object
                //Private m_oSpmMgr As object

                //‘SetData方法仅用于KIS专业版12.2及之后版本登陆窗体调用,前面版本不需要增加
                //‘Public Sub SetData()
                //‘    Set m_dctGlobalInfo = Createobject(“KFO.Dictionary“)
                //‘    SetProp GetDesktopWindow GetCurrentProcessId ObjPtr(m_dctGlobalInfo)
                //‘End Sub

                //Public Sub SetData()
                //    Set m_dctGlobalInfo = Createobject(“KFO.Dictionary“)
                //    SetProp GetDesktopWindow GetCurrentProcessId ObjPtr(m_dctGlobalInfo)
    
                //End Sub

                //‘SetData方法仅用于KIS专业版12.2及之后版本登陆窗体调用,前面版本不需要增加
                Type SetDatet = System.Type.GetTypeFromProgID(“KISSetDate.KISSetDateC“);
                object SetDateloginer = Activator.CreateInstance(SetDatet);
                object SetDateo = SetDatet.InvokeMember(“SetData“ BindingFlags.Default
                    | BindingFlags.InvokeMethod null SetDateloginer null);

                //创建
                Type t = System.Type.GetTypeFromProgID(“KISLogin.ClsLogin“);

                if (t == null)
                {
                    MessageBox.Show(“加载金蝶登录器失败需要安装金蝶客户端.“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Error);
                    return false;
                }
                object loginer = Activator.CreateInstance(t);
                if (loginer == null)
                {
                    MessageBox.Show(“加载金蝶登录器失败loginer为空“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Error);
                    return false;
                }
                //Login的方法参数
                object[] args = new object[] { “super“ “主控台“ true };
                //访问KISLogin.dll的Login方法,调用登陆窗口
                object o = t.InvokeMember(“Login“ BindingFlags.Default
                    | BindingFlags.InvokeMethod null loginer args);
                //获取指定属性的数据
                if (Convert.ToBoolean(o) == true)
                {
                    //ConnectString={Persist Security Info=True;Provider=

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        9803  2018-06-03 22:26  KingdeeLogin.cs
     文件       24576  2018-06-03 21:40  KISSetDate.dll

评论

共有 条评论