64-bit Support

 

64-bit Support

Previous pageReturn to chapter overviewNext page

CAD DLL includes native 64-bit support. If you have decided to develop the 64-bit version of your product using CAD DLL, you need to port your project to a new architecture.

 

First of all, you need IDE that has support for 64-bit applications development. To build 64-bit applications, Microsoft Visual Studio 2005/2008/2010/2012 or Embarcadero Delphi XE2/XE3 is required.

 

In Microsoft Visual Studio, you need to configure your application to target 64-bit platform. For more information on 64-bit platform support in Visual Studio please see 64-bit Applications.

 

To configure a project to target a 64-bit platform implement the following:

 

1. In the Build menu, click Configuration Manager.

2. In the Active solution platform list, select the x64 platform for the solution to target. If the platform does not exist in the list, select New.

3. In the New Solution Platform dialog box, select the x64 platform for the solution to target.

4. If you want to copy the settings from the current platform configuration, select the platform configuration to copy settings from and click OK.

Properties for all the projects targeting the 64-bit platform are updated, and the next build of the project will be optimized for 64-bit platforms.

 

Note: If you cannot create the 64-bit configuration of a project in Visual Studio, the problemlies in the absence of the 64-bit compiler. It is most likely that you have not enabled the X64 Compilers and Tools check box during Visual Studio installation. If it is so, launch the installer and install the missing items.

 

After configuring the project in Visual Studio, you need to update the managed source code to target 64-bit environment. Migrating of your code primarily consists in data structure alignment in order to provide correct transfer of structured information from unmanaged code to the managed one.

 

In C# and Visual Basic .NET you need to provide exact offsets for each field within the structure to aid in the marshaling of information. The following sample demonstrates setting the field offsets (in bytes) for members of the CADDATA structure:

 


[C#]

[StructLayout(LayoutKind.Explicit)]

public struct CADData

{

    [FieldOffset(0)] public ushort Tag;

    [FieldOffset(2)] public ushort Count;

    [FieldOffset(4)] public ushort TickCount;

    [FieldOffset(6)] public byte Flags;

    [FieldOffset(7)] public byte Style;

    [FieldOffset(8)] public int Dimension;

    [FieldOffset(12)] public IntPtr DashDots;

    [FieldOffset(20)] public int DashDotsCount;

    [FieldOffset(24)] public int Color;

    [FieldOffset(28)] public IntPtr Ticks;

    [FieldOffset(36)] public double Thickness;

    [FieldOffset(44)] public double Rotation;

    [FieldOffset(52)] public IntPtr Layer;

    [FieldOffset(60)] public IntPtr Text;

    [FieldOffset(68)] public IntPtr FontName;

    [FieldOffset(76)] public IntPtr Handle;

    [FieldOffset(84)] public int Undefined1;

    [FieldOffset(88)] public double Undefined2;

    [FieldOffset(96)] public double Undefined3;

    [FieldOffset(104)] public IntPtr CADExtendedData;

    [FieldOffset(112)] public CADPoint Point;           

    [FieldOffset(136)] public CADPoint Point1;

    [FieldOffset(160)] public CADPoint Point2;

    [FieldOffset(184)] public CADPoint Point3;

    [FieldOffset(208)] public double Radius, StartAngle, EndAngle;

    [FieldOffset(232)] public byte Ratio, EntityType;

    [FieldOffset(208)] public int Block;

    [FieldOffset(212)] public CADPoint Scale;

    [FieldOffset(208)] public double FHeight, FScale, RWidth, RHeight;

    [FieldOffset(240)] public byte HAlign, VAlign;

    [FieldOffset(208)] public IntPtr Points;

}


 

 

If you use Visual C++, you need to define the compiler’s alignment (or "packing") of structure members. The following sample demonstrates setting alignment for the CADDATA structure to 1 byte boundary:

 


[C++]

#pragma pack(push,1)

typedef struct _CADDATA

{

   WORD Tag;

   WORD Count;

   WORD TickCount;

   BYTE Flags;

   BYTE Style;    

   int Dimension;

   LPFPOINT DashDots;

   int DashDotsCount;

   int Color;

   LPVOID Ticks;

   sgFloat Thickness;

   sgFloat Rotation;

   PsgChar Layer;

   PsgChar Text;   

   PsgChar FontName;

   HANDLE Handle;

   int Undefined1;

   sgFloat Undefined2;

   sgFloat Undefined3;

   LPCADEXTENDEDDATA CADExtendedData;

 

   FPOINT Point1;

   FPOINT Point2;

   FPOINT Point3;

   FPOINT Point4;

 

   union

   {      

      struct

      {

         sgFloat Radius;

         sgFloat StartAngle;

         sgFloat EndAngle;

         sgFloat Ratio;

         BYTE EntityType;

      } Arc;

      struct

      {

         HANDLE Block;

         FPOINT Scale;

      } Blocks;

      struct

      {

         sgFloat FHeight;

         sgFloat FScale;

         sgFloat RWidth;

         sgFloat RHeight;

         BYTE HAlign;

         BYTE VAlign;

      } Text;

      LPFPOINT PolyPoints;

   } DATA;

} CADDATA, *LPCADDATA;

#pragma pack(pop)


 

 

In Embarcadero Delphi XE2/XE3 you need to configure your application for the 64-bit Windows target.

 

To create an application that targets the 64-bit platform, add the corresponding target platform in the following way:

1. Right-click the Target Platforms node in the Project Manager.

2. Click Add Target in the context menu.

3. Select 64-bit Windows in the Select Platform selection box, enable the Make the selected platform active checkbox to automatically activate the platform as it is added to your project. The name of the platform appears in boldface in the Target Platforms node of the Project Manager.

4. Click OK.

 

 

See Also

Unicode support  | CAD DLL structures


© 2003-2024 CADSoftTools

 

Go to CAD DLL