Home > Net >  C # call DLL function in debugging x64 platform flash back
C # call DLL function in debugging x64 platform flash back

Time:11-28

 [DllImport (" ACTS1011_64. DLL)] 
Public static extern Boolean ACTS1011_InitDeviceAD (IntPtr hDevice, ref PCle8914_PARA_AD pADPara);


Call external DLL function, parameter is a structure inside, I also defines the structure of the corresponding, debugging on x86 platform can, but will flash when x64 cut back and there is no reason

VC header file is
 typedef struct _ACTS1011_PARA_AD 
{
LONG bChannelArray [8].//sampling channel selection arrays, each control eight channels,=TRUE said the channel sample, otherwise don't sampling
LONG InputRange [8].//analog input range choose
LONG CouplingType [8].//coupling type (dc coupling, exchange coupling)
LONG InputImped [8].//input impedance control array, each control 8 channel (temporarily does not support)
LONG FreqDivision;//points frequency [1, 2147483647], external clock: sampling frequency=external clock frequency/points frequency; Other clock: frequency sampling frequency=reference frequency/points;
LONG SampleMode;//sampling mode (limited sampling, continuous sampling)
ULONG M_Length;//M length (word), delay trigger M delay points range [0, 4294967295], a finite sampling points delay trigger effective
ULONG N_Length;//N length (word), finite sampling points effective
//after the trigger M must be zero, N for effective reading points; Hardware delay trigger N for effective reading points;
//N * enabled channel number * trigger number must be 2048 integer times
LONG PFISel;//choose PFI function, see the following constants defined (boards, 8582, 8584 to support only)
LONG TriggerMode;//trigger mode select
LONG TriggerSource;
//trigger source choiceLONG TriggerDir;//triggers a direction (up and down down down/up/along edge trigger)
LONG TrigLevelVolt;//trigger level (range according to the analog input)
LONG TrigWindow; NS//sensitive trigger window unit, step by step for the card highest sampling rate of the sampling period; Up to 80 m, for example, step by step is 12.5 nS
ULONG TrigCount;//trigger setting, the default is 1, 0 means that the said infinite trigger, the function is available under the limited sampling only
LONG ReferenceClock;//reference clock select
LONG TimeBaseClock;//sampling time base to choose
LONG bMasterEn;//the main equipment can make
//=0: from the device, receiving synchronous trigger signal sent by a master device
//=1: the main equipment for its trigger signal from the device
//note: in many modules synchronization system, can only set one of the devices is given priority to, the rest should be set to the equipment, if only one equipment in the system or have more than one device but does not require the synchronization, all equipment must be set to
from the deviceLONG SyncTrigSignal;//synchronization trigger source
LONG bClkOutEn;//whether the clock output, the TRUE output
LONG ClkOutSel;//the clock output choose
LONG bTrigOutEn;//whether the trigger output, the TRUE output
LONG TrigOutPolarity;//trigger output polarity
LONG TrigOutWidth; NS//trigger pulse output width unit, [50, 50000] step 50 nS
BOOL bSaveFile;//is saved automatically=TRUE: save
TCHAR chFileName [256].//save the path and name, example: L "F: \ \ 1. Pci"
} ACTS1011_PARA_AD, * PACTS1011_PARA_AD;


In c # is
 public struct PCle8914_PARA_AD 
{
[MarshalAs (UnmanagedType ByValArray, SizeConst=8)]
Public long [] bChannelArray;//sampling channel select array, each control channel,=TRUE said the channel sample, otherwise don't sampling (only support channel configuration: 0 01 0123)
[MarshalAs (UnmanagedType ByValArray, SizeConst=8)]
Public long [] InputRange;//analog input range choose
[MarshalAs (UnmanagedType ByValArray, SizeConst=8)]
Public long [] CouplingType;//coupling type (dc coupling, exchange coupling)
[MarshalAs (UnmanagedType ByValArray, SizeConst=8)]
Public long [] InputImped;//input impedance control array, each control 8 channel (temporarily does not support)
Public long FreqDivision;//points frequency [1, 2147483647], external clock: sampling frequency=external clock frequency/points frequency; Other clock: frequency sampling frequency=reference frequency/points;
Public long SampleMode;//sampling mode (limited sampling, continuous sampling)
Public long M_Length;//M length (word), delay trigger M delay points range/0, 2147483647
Public long N_Length;//N length (words)
//intermediate trigger M N read points effectively; Triggered after the M must be, N read points effectively; Trigger M must be, N effective reading points; Hardware delay trigger N read points effectively;
//for effective reading under different trigger points combined range [16/can make the channel number, memory size (bytes)/2/can make channel number], effective reading points together must be (16/can make channel number) integer times
Public long PFISel;//choose PFI function, see the following constants defined (boards, 8582, 8584 to support only)
Public long TriggerMode;//trigger mode select
Public long TriggerSource;
//trigger source choicePublic long TriggerDir;//triggers a direction (positive/negative trigger)
Public long TrigLevelVolt;//trigger level (range according to the analog input)
Public long TrigWindow; NS//sensitive trigger window unit, step 5 nS

Public ulong TrigCount;//trigger setting, by default, this function only in the trigger and hardware delay trigger mode effectively, can trigger the number effective reading points * * channel number * 2 & lt;=memory size (bytes)
Public long ReferenceClock;//reference clock select
Public long TimeBaseClock;//sampling time base to choose
Public long bMasterEn;//the main equipment can make
//=0: from the device, receiving synchronous trigger signal sent by a master device
//=1: the main equipment for its trigger signal from the device
//note: in many modules synchronization system, can only set one of the devices is given priority to, the rest should be set to the equipment, if only one equipment in the system or have more than one device but does not require the synchronization, all equipment must be set to
from the devicePublic long SyncTrigSignal;//synchronization trigger source
Public long bClkOutEn;//whether the clock output, the TRUE output
Public long ClkOutSel;//the clock output choose
Public long bTrigOutEn;//whether the trigger output, the TRUE output 16
Public long TrigOutPolarity;//trigger output polarity
Public long TrigOutWidth; NS//trigger pulse output width unit, [50, 50000] step nS
Public bool bSaveFile;//is saved automatically=TRUE: save
[MarshalAs (UnmanagedType ByValArray, SizeConst=256)]
Public char [] chFileName;//save the path and name, such as "F: \ \ 1. Pci"
}

CodePudding user response:

The corresponding c # 1. C + + long int the corresponding c # long long long
2. TCHAR according to different digits are not the same as a character encoding is likely to be a byte is likely to be 2 or 4 bytes

CodePudding user response:

In c # structure above plus [StructLayout (LayoutKind. Sequential, Pack=1, CharSet=CharSet. Ansi)] this

CodePudding user response:

refer to the second floor OrdinaryCoder response:
on c # structure with [StructLayout (LayoutKind. Sequential, Pack=1, CharSet=CharSet. Ansi)] this

Added or flash back to front to int

CodePudding user response:

refer to the second floor OrdinaryCoder response:
on c # structure with [StructLayout (LayoutKind. Sequential, Pack=1, CharSet=CharSet. Ansi)] this

Focus is cut with 32-bit x86 platform DLL is ok but x64 cut with a 64 - bit DLL doesn't (work well)

CodePudding user response:

Seem to be the reason this type of tchar variables will change

CodePudding user response:

DLL is written by yourself, please change the interface to char a bit better if not packed in the CLI or c + +

CodePudding user response:

Exe and DLL architecture must at the same time as the x86 or x64
And long in c # and c + + long length is not necessarily the same
Best written in c # Int64, Int32 thisnullnullnullnullnullnullnullnull
  • Related