Author Topic: acedPostCommand  (Read 4322 times)

0 Members and 1 Guest are viewing this topic.

cannorth

  • Guest
acedPostCommand
« on: March 18, 2014, 03:33:17 PM »
Hello,

  How do you declare this properly for VB.Net, Visual Studio 2010:

    Private Declare Auto Function acedPostCommand Lib "acad.exe" Alias "?acedPostCommand@@YAHPB_W@Z" (ByVal strExpr As String) As Integer

Thanks,

Mike

exmachina

  • Guest
Re: acedPostCommand
« Reply #1 on: March 18, 2014, 03:56:21 PM »
<DllImport("acad.exe", CallingConvention := CallingConvention.Cdecl, CharSet := CharSet.Unicode, EntryPoint := "?acedPostCommand@@YAHPB_W@Z")> _
Private Shared Function acedPostCommand(ByVal expr As String) As Integer
End Function

Please, also read:
http://www.theswamp.org/index.php?topic=37890.0

cannorth

  • Guest
Re: acedPostCommand
« Reply #2 on: March 18, 2014, 04:15:21 PM »
I changed the DLL import to that, but it's the Declare I'm having problems.

exmachina

  • Guest
Re: acedPostCommand
« Reply #3 on: March 18, 2014, 04:34:16 PM »
I changed the DLL import to that, but it's the Declare I'm having problems.

Declare == VB6 compatibility, this is not required in .NET

Please send an example (full source code) where it is possible to reproduce the problem.

For your information
I do not speak English, so please excuse any mistakes.

cannorth

  • Guest
Re: acedPostCommand
« Reply #4 on: March 18, 2014, 04:37:06 PM »
Code: [Select]
Public Class Test

    Private Declare Auto Function acedPostCommand Lib "acad.exe" Alias "?acedPostCommand@@YAHPB_W@Z" (ByVal strExpr As String) As Integer


    <DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode, EntryPoint:="?acedPostCommand@@YAHPB_W@Z")> _
    Private Shared Function acedPostCommand(ByVal expr As String) As Integer
    End Function
End Class

exmachina

  • Guest
Re: acedPostCommand
« Reply #5 on: March 18, 2014, 04:59:17 PM »
Code: [Select]
Public Class Test

    Private Declare Auto Function acedPostCommand Lib "acad.exe" Alias "?acedPostCommand@@YAHPB_W@Z" (ByVal strExpr As String) As Integer


    <DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode, EntryPoint:="?acedPostCommand@@YAHPB_W@Z")> _
    Private Shared Function acedPostCommand(ByVal expr As String) As Integer
    End Function
End Class


Code - vb.net: [Select]
  1. Imports System.Runtime.InteropServices
  2.  
  3. Friend NotInheritable Class Test
  4.     <DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode, EntryPoint:="?acedPostCommand@@YAHPB_W@Z")> _
  5.     Private Shared Function acedPostCommand32(ByVal expr As String) As Integer
  6.     End Function
  7.  
  8.     <DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode, EntryPoint:="?acedPostCommand@@YAHPEB_W@Z")> _
  9.     Private Shared Function acedPostCommand64(ByVal expr As String) As Integer
  10.     End Function
  11.  
  12.     Public Shared Function acedPostCommand(ByVal expr As String) As Integer
  13.         If IntPtr.Size = 4 Then ' 32-bit
  14.             Return acedPostCommand32(expr)
  15.         End If
  16.         ' else 32-bit
  17.         Return acedPostCommand64(expr)
  18.     End Function
  19. End Class
  20.  
  21.  
  22. Class Testit
  23.     Sub callit()
  24.         Test.acedPostCommand("aEioU")
  25.     End Sub
  26. End Class