<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Determine 32- or 64-bit application in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747296#M51754</link>
    <description>&lt;PRE&gt;public static bool IsX64()
{
   if (IntPtr.Size == 4) return false;
             else        return true;
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Sample of using: &lt;A href="https://forums.autodesk.com/t5/NET/Can-t-find-ModelessOperationWill-Start-Event-in-Dot-net/m-p/3447691#M28761" target="_blank"&gt;http://forums.autodesk.com/t5/NET/Can-t-find-ModelessOperationWill-Start-Event-in-Dot-net/m-p/3447691#M28761&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Other example: &lt;A href="http://forums.autodesk.com/t5/NET/Save-a-password-protected-drawing-without-password-with-VB-NET/m-p/3451134#M28809" target="_blank"&gt;http://forums.autodesk.com/t5/NET/Save-a-password-protected-drawing-without-password-with-VB-NET/m-p/3451134#M28809&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jan 2013 15:59:43 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2013-01-07T15:59:43Z</dc:date>
    <item>
      <title>Determine 32- or 64-bit application</title>
      <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747266#M51753</link>
      <description>&lt;P&gt;I am using a dllimport from accore.dll, but the entry point for the method in the dll differs between 32-bit and 64-bit version of AutoCAD. How can I check whether the AutoCAD application is a 32- or 64-bit version, i.e. the dll is 32- or 64-bit?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2013 15:31:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747266#M51753</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-07T15:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Determine 32- or 64-bit application</title>
      <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747296#M51754</link>
      <description>&lt;PRE&gt;public static bool IsX64()
{
   if (IntPtr.Size == 4) return false;
             else        return true;
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Sample of using: &lt;A href="https://forums.autodesk.com/t5/NET/Can-t-find-ModelessOperationWill-Start-Event-in-Dot-net/m-p/3447691#M28761" target="_blank"&gt;http://forums.autodesk.com/t5/NET/Can-t-find-ModelessOperationWill-Start-Event-in-Dot-net/m-p/3447691#M28761&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Other example: &lt;A href="http://forums.autodesk.com/t5/NET/Save-a-password-protected-drawing-without-password-with-VB-NET/m-p/3451134#M28809" target="_blank"&gt;http://forums.autodesk.com/t5/NET/Save-a-password-protected-drawing-without-password-with-VB-NET/m-p/3451134#M28809&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2013 15:59:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747296#M51754</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-07T15:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Determine 32- or 64-bit application</title>
      <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747357#M51755</link>
      <description>&lt;P&gt;Hi Alexander,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public static bool IsX64()
{
   return IntPtr.Size == 8;
}&lt;/PRE&gt;&lt;P&gt;is less verbose and quite self explanatory.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2013 16:42:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747357#M51755</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2013-01-07T16:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Determine 32- or 64-bit application</title>
      <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747655#M51756</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt; wrote:&lt;BR /&gt;is less verbose and quite self explanatory.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN class="short_text"&gt;&lt;SPAN class="hps"&gt;Totally agree!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2013 21:37:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747655#M51756</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-07T21:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Determine 32- or 64-bit application</title>
      <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747960#M51757</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I didn't know about the IntPtr.size, so thank you for that information. But in my case I can't use this since I can't get IntPtr.size directly in a class where the dllimport is happening. You have to be whithin a method to use it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead I used&amp;nbsp;conditional compilation symbols and I compile one dll for 32-bit and one for 64-bit. By using the&amp;nbsp;conditional compilation symbols the correct part of the code is compiled for each build.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2013 12:19:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747960#M51757</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-08T12:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Determine 32- or 64-bit application</title>
      <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747970#M51758</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;But in my case I can't use this since I can't get IntPtr.size directly in a class where the dllimport is happening. You have to be whithin a method to use it. &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why? &lt;SPAN class="short_text"&gt;&lt;SPAN class="hps"&gt;Did you watch&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the examples&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to which I referred&lt;/SPAN&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2013 12:30:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747970#M51758</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-08T12:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Determine 32- or 64-bit application</title>
      <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747972#M51759</link>
      <description>&lt;P&gt;Yes, you're right. That might be easier leaving everything in one dll.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2013 12:33:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3747972#M51759</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-08T12:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Determine 32- or 64-bit application</title>
      <link>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3748030#M51760</link>
      <description>&lt;P&gt;Sample that demonstrate common source code for different AutoCAD version and Platform (32 or 64 bit):&lt;/P&gt;
&lt;PRE&gt;using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using AcAp = Autodesk.AutoCAD.ApplicationServices;

[assembly: CommandClass(typeof(Rivilis.HookESC))]

namespace Rivilis
{
  public static class HookESC
  {
    static int AcadVer = AcAp.Application.Version.Major;
    // For AutoCAD 2007 - 2012 64 bit
    [DllImport("acad.exe", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, 
      EntryPoint = "?acedRegisterFilterWinMsg@@YAHQ6AHPEAUtagMSG@@@Z@Z")]
    private static extern int acedRegisterFilterWinMsg2012x64(WindowHookProc callBackFunc);
    [DllImport("acad.exe", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, 
      EntryPoint = "?acedRemoveFilterWinMsg@@YAHQ6AHPEAUtagMSG@@@Z@Z")]
    private static extern int acedRemoveFilterWinMsg2012x64(WindowHookProc callBackFunc);
    // For AutoCAD 2007 - 2012 32 bit
    [DllImport("acad.exe", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, 
      EntryPoint = "?acedRegisterFilterWinMsg@@YAHQ6AHPAUtagMSG@@@Z@Z")]
    private static extern int acedRegisterFilterWinMsg2012x32(WindowHookProc callBackFunc);
    [DllImport("acad.exe", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, 
      EntryPoint = "?acedRemoveFilterWinMsg@@YAHQ6AHPAUtagMSG@@@Z@Z")]
    private static extern int acedRemoveFilterWinMsg2012x32(WindowHookProc callBackFunc);
    // For AutoCAD 2013 64 bit
    [DllImport("accore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, 
      EntryPoint = "?acedRegisterFilterWinMsg@@YAHQ6AHPEAUtagMSG@@@Z@Z")]
    private static extern int acedRegisterFilterWinMsg2013x64(WindowHookProc callBackFunc);
    [DllImport("accore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, 
      EntryPoint = "?acedRemoveFilterWinMsg@@YAHQ6AHPEAUtagMSG@@@Z@Z")]
    private static extern int acedRemoveFilterWinMsg2013x64(WindowHookProc callBackFunc);
    // For AutoCAD 2013 32 bit
    [DllImport("accore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, 
      EntryPoint = "?acedRegisterFilterWinMsg@@YAHQ6AHPAUtagMSG@@@Z@Z")]
    private static extern int acedRegisterFilterWinMsg2013x32(WindowHookProc callBackFunc);
    [DllImport("accore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, 
      EntryPoint = "?acedRemoveFilterWinMsg@@YAHQ6AHPAUtagMSG@@@Z@Z")]
    private static extern int acedRemoveFilterWinMsg2013x32(WindowHookProc callBackFunc);

    private static int acedRegisterFilterWinMsg(WindowHookProc callBackFunc)
    {
      if (AcadVer &amp;gt;= 19) {
        if (IntPtr.Size == 4) return acedRegisterFilterWinMsg2013x32(callBackFunc); 
                  else        return acedRegisterFilterWinMsg2013x64(callBackFunc);
      } else {
        if (IntPtr.Size == 4) return acedRegisterFilterWinMsg2012x32(callBackFunc);
                  else        return acedRegisterFilterWinMsg2012x64(callBackFunc);
      }
    }
    private static int acedRemoveFilterWinMsg(WindowHookProc callBackFunc)
    {
      if (AcadVer &amp;gt;= 19) {
        if (IntPtr.Size == 4) return acedRemoveFilterWinMsg2013x32(callBackFunc);
                 else         return acedRemoveFilterWinMsg2013x64(callBackFunc);
      }
      else {
        if (IntPtr.Size == 4) return acedRemoveFilterWinMsg2012x32(callBackFunc);
                 else         return acedRemoveFilterWinMsg2012x64(callBackFunc);
      }
    }

    // hook message filter callback function
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate int WindowHookProc(ref Message msg);
    private static WindowHookProc callBackFunc = null;

    private static int WindowsHook(ref Message msg)
    {
      if (msg.Msg == 0x0100 &amp;amp;&amp;amp; msg.WParam == (IntPtr)0x1b) {
        // MessageBox.Show("ESC pressed"); // &amp;lt;- your's action
        // acedRemoveFilterWinMsg(callBackFunc); // &amp;lt;- unregister callback
      }
      return 0;
    }

    [CommandMethod("SetHookEsc")]
    public static void SetHookEsc()
    {
      callBackFunc = new WindowHookProc(WindowsHook);
      acedRegisterFilterWinMsg(callBackFunc);
    }
    [CommandMethod("UnsetHookEsc")]
    public static void UnsetHookEsc()
    {
      if (callBackFunc != null) acedRemoveFilterWinMsg(callBackFunc);
    }
  }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2013 13:26:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/determine-32-or-64-bit-application/m-p/3748030#M51760</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-08T13:26:08Z</dc:date>
    </item>
  </channel>
</rss>

