Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to call the function in cellcore.dll?

How to call the function in cellcore.dll?

Scheduled Pinned Locked Moved C#
tutorialhostingcloudhelpquestion
23 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D DaveyM69

    Can you post your function and struct declarations?

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    W Offline
    W Offline
    whiteclouds
    wrote on last edited by
    #21
        public bool OpenLine()
        {
            UInt32 dwDevNum = 0;//count the devices
            UInt32 dwApiVerSion = TAPI\_CURRENT\_VERSION;
            LINEINITIALIZEEXPARAMS dtParams = new LINEINITIALIZEEXPARAMS();
            dtParams.dwTotalSize = (UInt32)Marshal.SizeOf(dtParams);
            dtParams.dwOptions = 1;
            IntPtr handles = new IntPtr(0);
    
            IntPtr hInstance = IntPtr.Zero;//new IntPtr(GetModuleHandle(new IntPtr(0)).ToInt32());
            unsafe
            {
                fixed(IntPtr \*hLineApp = &m\_hLineApp)
                {
                    long lResult = lineInitializeEx(hLineApp, hInstance, new IntPtr(0), new IntPtr(0),
                        new IntPtr(&dwDevNum), new IntPtr(&dwApiVerSion), new IntPtr(&dtParams));
                    if (lResult == 0)
                    {
                        return true;
                    }
                }
                return false;
            }
        }
        \[StructLayout(LayoutKind.Sequential)\]
        private struct LINEINITIALIZEEXPARAMS
        {
            public uint dwTotalSize;
            public uint dwNeededSize;
            public uint dwUsedSize;
            public uint dwOptions;
            public IntPtr hMultiUse;  
            public uint dwCompletionKey;
        }
        \[DllImport("coredll.dll", SetLastError = true)\]
        unsafe private static extern uint lineInitializeEx(
            IntPtr \*lphLineApp,
            IntPtr hInstance,
            IntPtr pfnCallback,//lineCallbackFunc lpfnCallback,
            IntPtr FriendAppName,//StringBuilder lpszFriendlyAppName,
            IntPtr pNumDevs,//out uint lpdwNumDevs,
            IntPtr pAPIVersion,//out uint lpdwAPIVersion,
            IntPtr pLineInitializeExParams);//ref LINEINITIALIZEEXPARAMS lpLineInitializeExParams);
    

    There is some white cloud floating on the blue sky. That's the landscape I like.

    D 1 Reply Last reply
    0
    • W whiteclouds
          public bool OpenLine()
          {
              UInt32 dwDevNum = 0;//count the devices
              UInt32 dwApiVerSion = TAPI\_CURRENT\_VERSION;
              LINEINITIALIZEEXPARAMS dtParams = new LINEINITIALIZEEXPARAMS();
              dtParams.dwTotalSize = (UInt32)Marshal.SizeOf(dtParams);
              dtParams.dwOptions = 1;
              IntPtr handles = new IntPtr(0);
      
              IntPtr hInstance = IntPtr.Zero;//new IntPtr(GetModuleHandle(new IntPtr(0)).ToInt32());
              unsafe
              {
                  fixed(IntPtr \*hLineApp = &m\_hLineApp)
                  {
                      long lResult = lineInitializeEx(hLineApp, hInstance, new IntPtr(0), new IntPtr(0),
                          new IntPtr(&dwDevNum), new IntPtr(&dwApiVerSion), new IntPtr(&dtParams));
                      if (lResult == 0)
                      {
                          return true;
                      }
                  }
                  return false;
              }
          }
          \[StructLayout(LayoutKind.Sequential)\]
          private struct LINEINITIALIZEEXPARAMS
          {
              public uint dwTotalSize;
              public uint dwNeededSize;
              public uint dwUsedSize;
              public uint dwOptions;
              public IntPtr hMultiUse;  
              public uint dwCompletionKey;
          }
          \[DllImport("coredll.dll", SetLastError = true)\]
          unsafe private static extern uint lineInitializeEx(
              IntPtr \*lphLineApp,
              IntPtr hInstance,
              IntPtr pfnCallback,//lineCallbackFunc lpfnCallback,
              IntPtr FriendAppName,//StringBuilder lpszFriendlyAppName,
              IntPtr pNumDevs,//out uint lpdwNumDevs,
              IntPtr pAPIVersion,//out uint lpdwAPIVersion,
              IntPtr pLineInitializeExParams);//ref LINEINITIALIZEEXPARAMS lpLineInitializeExParams);
      

      There is some white cloud floating on the blue sky. That's the landscape I like.

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #22

      Not too sure where the problem is. The first thing I'd do is get rid of the *, &, unsafe and fixed pointer stuff. It's rarely needed as the built in marshaller can handle this stuff way better. I doubt it's the cause of your problems but declaring dwDevNum and creating a pointer from it's address is not going to work. There are two keywords for passing value types by reference (thier pointer), ref and out. If a value needs to be passed into a function then use ref. If the function doesn't need a value but there will be one there after the function returns then use out. In the case of dwDevNum this should be out but lpdwAPIVersion and dtParams should be ref. As IntPtr is a value type the pointer to a pointer for lphLineApp can be done using ref/out as well. To the solution... have a look at this[^]. The guy says his C# code works.

      Dave
      Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

      W 1 Reply Last reply
      0
      • D DaveyM69

        Not too sure where the problem is. The first thing I'd do is get rid of the *, &, unsafe and fixed pointer stuff. It's rarely needed as the built in marshaller can handle this stuff way better. I doubt it's the cause of your problems but declaring dwDevNum and creating a pointer from it's address is not going to work. There are two keywords for passing value types by reference (thier pointer), ref and out. If a value needs to be passed into a function then use ref. If the function doesn't need a value but there will be one there after the function returns then use out. In the case of dwDevNum this should be out but lpdwAPIVersion and dtParams should be ref. As IntPtr is a value type the pointer to a pointer for lphLineApp can be done using ref/out as well. To the solution... have a look at this[^]. The guy says his C# code works.

        Dave
        Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

        W Offline
        W Offline
        whiteclouds
        wrote on last edited by
        #23

        I will study the code you provided. Thank you!

        There is some white cloud floating on the blue sky. That's the landscape I like.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups