662
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace PB_test
{
public class Class1
{
public static string test(string fydh, string fydscsj)
{
string result = "";
int fyd_retrun = 0;
string message = "调用测试开始";
result = "0";
if (fydh == "0")
{
message = "请传入正确的号码";
}
else
{
if (int.TryParse(fydh.ToString(), out fyd_retrun))
{
message = "成功获取号码:" + fyd_retrun;
string strings = fydh + " " + fydscsj;
result = "1";
}
else
{
message = "传入的号码格式有误:" + fydh;
result = "0";
}
}
return message +";当前状态:" +result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices; //该引用必须
namespace PB_tests
{
[Guid("8C4FAF54-1484-4C86-B734-1B6441C4892E")] //利用GUID生成器随机生成,大家上网查如何生成,必须
public interface CallParamers
{
[DispId(1)]
string PBCAll(string hm, DateTime fssj, ref int result);
}
[Guid("44490EDD-582C-4618-9831-81C2237C7759")] //利用GUID生成器随机生成,大家上网查如何生成,必须
[ClassInterface(ClassInterfaceType.None)]
public class Class1 : CallParamers
{
public string PBCAll(string hm, DateTime fssj, ref int result)
{
int hm_retrun = 0;
string message = "调用测试开始";
result = 0;
if (hm == "0")
{
message = "请传入正确的号码";
}
else
{
if (int.TryParse(hm.ToString(), out hm_retrun))
{
message = "成功获取号码:" + hm_retrun;
string strings = hm+ " " + fssj;
result = 1;
}
else
{
message = "传入的号码格式有误:" + hm;
result = 0;
}
}
return message;
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("PB_tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("PB_tests")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(true)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("cc9871a2-2d46-47b7-ac9b-2069036050fe")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
string messages
string fydh
date fysj
int returns
int flag
fydh ='aaaa'
fysj =today()
returns =0
OleObject Oleb
Oleb = Create OLEObject
flag = Oleb.ConnectToNewObject("PB_tests.Class1") //PB_tests为C#中命名空间(namespace) ,Class1为C#中类名
if flag <>0 then
MessageBox("提示","PB调用C#COM组件失败,返回消息")
return
end if
messages =Oleb.PBCall(fydh ,fysj ,ref returns)
MessageBox("提示",messages)
open(pbcall)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace PB_test
{
public interface ITestClass
{
static string test(string fydh, string fydscsj);
}
[ClassInterface(ClassInterfaceType.None)]
public class Class1:ITestClass
{
public static string test(string fydh, string fydscsj)
{
string result = "";
int fyd_retrun = 0;
string message = "调用测试开始";
result = "0";
if (fydh == "0")
{
message = "请传入正确的号码";
}
else
{
if (int.TryParse(fydh.ToString(), out fyd_retrun))
{
message = "成功获取号码:" + fyd_retrun;
string strings = fydh + " " + fydscsj;
result = "1";
}
else
{
message = "传入的号码格式有误:" + fydh;
result = "0";
}
}
return message +";当前状态:" +result;
}
}
}