All pastes #611371 Raw Edit

Something

public text v1 · immutable
·published 2007-07-09 21:58 UTC
rendered paste body
HRESULT RIL_DevSpecific(
    HRIL hRil,                          // @parm handle to RIL instance returned by <f RIL_Initialize>
    const BYTE* lpbParams,              // @parm parameters for the operation to be performed
    DWORD dwSize                        // @parm size of the data pointed to by <p lpParams> in bytes
);

typedef struct tagRILDevSpecificParams {
        DWORD dwFunctionID;
        BYTE *lpInputParameters;
        BYTE *lpOutputParameters;
} RIL_DEVSPECIFIC_PARAMS, *lpRIL_DEVSPECIFIC_PARAMS;

//Now my C# Code:

        [DllImport("ril.dll")]
        private static extern IntPtr RIL_DevSpecific(IntPtr hRil, ref IntPtr parm, IntPtr dwSize);
        #endregion   

            RIL_DEVSPECIFIC_PARAMS lbpParams = new RIL.RIL_DEVSPECIFIC_PARAMS();
            byte[] lpOut = new byte[256];
            lbpParams.dwFunctionID = 0x33;
            lbpParams.lpInputParameters = new byte[256];
            lbpParams.lpInputParameters = System.Text.ASCIIEncoding.ASCII.GetBytes(szCmd);
            lbpParams.lpOutputParameters = lpOut;
            int sizOf = Marshal.SizeOf(lbpParams); //here's the first error.
            IntPtr ptr = Marshal.AllocHGlobal(sizOf);
            Marshal.StructureToPtr(lbpParams, ptr, true);
            res = RIL_DevSpecific(hRil, ref ptr, (IntPtr)Marshal.SizeOf(lbpParams));