读书人

关于API的难题,该如何处理

发布时间: 2012-01-18 00:23:26 作者: rapoo

关于API的难题
现在我有一个API程序IdealCopy.exe,估计是用VS2005开发出来的。
我想把它引入到我的程序中去,可是失败了。应该怎样引用呢? 我在VS.net 2003中尝试自动引用,结果提示说不是有效的DLL库或COM组件。

IdealCopy的定义如下:
Namespace ConsoleApplication1
Friend Class Program
' Methods
Public Sub New()
Private Shared Sub code(ByVal v As UInt32(), ByVal k As UInt32())
Private Shared Function ConvertStringToUInt(ByVal Input As String) As UInt32
Private Shared Function ConvertUIntToString(ByVal Input As UInt32) As String
Private Shared Sub decode(ByVal v As UInt32(), ByVal k As UInt32())
Private Shared Function Decrypt(ByVal Data As String, ByVal Key As String) As String
Private Shared Function Encrypt(ByVal Data As String, ByVal Key As String) As String
Private Shared Function FormatKey(ByVal Key As String) As UInt32()
Public Shared Function IdealCopy(ByVal args As String()) As Integer
Public Shared Function IdealCopyCos(ByVal args As String()) As Boolean
Public Shared Function IdealCopyPos(ByVal args As String()) As Boolean
Public Shared Sub Main(ByVal args As String())

' Properties
Public Shared Property objWriter As StreamWriter

' Fields
Private Shared objwriter As StreamWriter
End Class
End Namespace
Public Shared Function IdealCopy(ByVal args As String()) As Integer
Dim num1 As Integer = 0


If Program.IdealCopyCos(args) Then
num1 += 1
End If
If ((num1 > 0) AndAlso Program.IdealCopyPos(args)) Then
num1 += 1
End If
Return num1
End Function

我需要做的是获取IdealCopy的返回值。我的调用方式如下:
<DllImport( "IdealCopy.exe ", _
EntryPoint:= "ConsoleApplication1.Program.IdealCopy ")> _
Public Shared Function IdealCopy(ByVal args As String()) As Int32

End Function

Dim arg As String() = {orderID, DNS, errorLog, Login, Password}
MessageBox.Show(IdealCopy(arg))

但实际运行时却提示无法找到“ConsoleApplication1.Program.IdealCopy”入口。

请问我应该如何实现呢?





[解决办法]
你说 IdealCopy.exe 是控制台程序? 在自己的程序里面执行后取到 IdealCopy.exe 的输出,在程序中抓取?
按照控制台程序编写就行了。



[解决办法]
up
[解决办法]
不行需要是dll
[解决办法]
是的 需要dll类型

读书人网 >C#

热点推荐