First, call the dll and register it through the command: regsvr32 F:/CJZFProject/CJZFMain/bin/Debug/PayDll. DLL
If you call the standard DLL Code as follows:
Statement:
[DllImport ("PayDll. dll", CharSet = CharSet. Auto)]
Static extern int OpenComm (int a, int B );
Call:
Int c = 10; int d = 20;
Int num = OpenComm (c, d );
If it is a dll written in vb, it is a non-standard dll and cannot be called dynamically. You can use:
System. Type oType_C = System. Type. GetTypeFromProgID ("PayDll. ClsLogin ");
Object o_C = System. Activator. CreateInstance (oType_C );
// Assign a value to the vZth attribute of the o_C object
OType_C.InvokeMember ("vZth", System. Reflection. BindingFlags. SetProperty, null, o_C, new object [] {"001 "});
// Execution Method
Object result = oType_C.InvokeMember ("Login", System. Reflection. BindingFlags. InvokeMethod, null, o_C, new object [] {"sa", "", "000 "});
// Obtain the returned value
ResultStr = result. ToString ();
// Obtain the value of the o_c attribute vname after the method is executed.
Object vname = otype_c.invokemember ("vzth", system. reflection. bindingflags. getproperty, null, o_c, null );
First, call the DLL and register it through the command: regsvr32 F:/cjzfproject/cjzfmain/bin/debug/paydll. dll
If you call the standard DLL Code as follows:
Statement:
[Dllimport ("paydll. dll", charset = charset. Auto)]
Static extern int opencomm (int A, int B );
Call:
Int c = 10; int d = 20;
Int num = opencomm (c, d );
If it is a DLL written in VB, it is a non-standard DLL and cannot be called dynamically. You can use:
System. Type otype_c = system. type. gettypefromprogid ("paydll. clslogin ");
Object o_c = system. activator. createinstance (otype_c );
// Assign a value to the vzth attribute of the o_c object
Otype_c.invokemember ("vzth", system. reflection. bindingflags. setproperty, null, o_c, new object [] {"001 "});
// Execution Method
Object result = oType_C.InvokeMember ("Login", System. Reflection. BindingFlags. InvokeMethod, null, o_C, new object [] {"sa", "", "000 "});
// Obtain the returned value
ResultStr = result. ToString ();
// Obtain the value of the o_C attribute vName after the method is executed.
Object vName = oType_C.InvokeMember ("vZth", System. Reflection. BindingFlags. GetProperty, null, o_C, null );