Jump to content

Recommended Posts

Posted

Hello,

I'm having serious problems understanding DllCall or rather what parameters I have to use.

The C# code is:

using System;
using System.Runtime.InteropServices;

namespace ApsDemo
{
    class APS
    {
        [DllImport("sensor.dll")]
        public static extern void ShockproofGetAccelerometerData(ref AccData accData);

        [StructLayout(LayoutKind.Sequential)]
        public struct AccData
        {
            internal int status;
            internal short x;
            internal short y;
        }
    }

All attempts I did ended in the normal windows error report :)

I would really appreciate if someone could help me reading those variables!

P.S: full code

Posted

My guess is that you need something like this

$AccData = DllStructCreate("int;short;short")

$res = DllCall("sensor.dll","none","ptr",DllStructGetPtr($AccData))

$status = DllStructGetData($AccData,1)

$shortx = = DllStructGetData($AccData,2)

$shorty = = DllStructGetData($AccData,3)

[code=auto:0]

but it's a guess because I don't know how the dll deals with a struct passed by reference.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

Thanks so much for the help!

I have been using the German help file, which just doesn't list the DllStructCreate function... an error I won't repeat :)

Posted

Thanks so much for the help!

I have been using the German help file, which just doesn't list the DllStructCreate function... an error I won't repeat :)

NP.

I hadn't noticed that was your first post so welcome to the AutoIt forums!

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...