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.
  • L Luc Pattyn

    That looks OK; there is one union, all its members are starting at the same offset (4), and nothing is following the union (both inner structs are inside the union, the union is the last member of the outer struct). :)

    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

    Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

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

    :thumbsup:

    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)

    1 Reply Last reply
    0
    • W whiteclouds

      I am pleasure to see your answer. Thank you! But I have still a problem. As the code you show, the struct LINEINITIALIZEEXPARAMS has two elements: hEvent and hCompletionPort. But in C++, this struct has a union. The element in it have the same name as your code. I know the keyword "union" isn't exist in C#. But I think this struct shouldn't be declare as this. Additional, I can't still execute this program. The error is still "No entry point found for lineInitializeEx". I hope you can help me again. Thx!

      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
      #14

      Following the discussion I had with Luc, I've done some investigation into the way uinions work, and he is correct, the parameters inside the union block start at the same place in memory - in otherwords, the struct will contain one of the handles but not both so the best way to declare it is:

      [StructLayout(LayoutKind.Sequential)]
      private struct LINEINITIALIZEEXPARAMS
      {
      public uint dwTotalSize;
      public uint dwNeededSize;
      public uint dwUsedSize;
      public uint dwOptions;
      public IntPtr handle; // Will be either hEvent OR hCompletionPort
      public uint dwCompletionKey;
      }

      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

        Following the discussion I had with Luc, I've done some investigation into the way uinions work, and he is correct, the parameters inside the union block start at the same place in memory - in otherwords, the struct will contain one of the handles but not both so the best way to declare it is:

        [StructLayout(LayoutKind.Sequential)]
        private struct LINEINITIALIZEEXPARAMS
        {
        public uint dwTotalSize;
        public uint dwNeededSize;
        public uint dwUsedSize;
        public uint dwOptions;
        public IntPtr handle; // Will be either hEvent OR hCompletionPort
        public uint dwCompletionKey;
        }

        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
        #15

        I'm glad to see your answer. But now I meet a new problem, that I can't get HINSTANCE. I had find some ways in MSDN. But no available way I found. Could you be kind to help me again? Thank you! :)

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

        modified on Monday, September 13, 2010 2:03 AM

        D 1 Reply Last reply
        0
        • W whiteclouds

          I'm glad to see your answer. But now I meet a new problem, that I can't get HINSTANCE. I had find some ways in MSDN. But no available way I found. Could you be kind to help me again? Thank you! :)

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

          modified on Monday, September 13, 2010 2:03 AM

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

          MSDN says: "Instance handle of the client application or DLL. The application or DLL can pass NULL for this parameter, in which case TAPI uses the module handle of the root executable of the process (for purposes of identifying call handoff targets and media mode priorities). The clue is "can pass NULL", which in the case of PInvoke handles is IntPtr.Zero. That should work. If not, have a look at the Process.Handle[^] property - perhaps this will work?

          IntPtr hInstance = System.Diagnostics.Process.GetCurrentProcess().Handle;

          and pass hInstance as the parameter..., I prefer IntPtr.Zero though!

          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

            MSDN says: "Instance handle of the client application or DLL. The application or DLL can pass NULL for this parameter, in which case TAPI uses the module handle of the root executable of the process (for purposes of identifying call handoff targets and media mode priorities). The clue is "can pass NULL", which in the case of PInvoke handles is IntPtr.Zero. That should work. If not, have a look at the Process.Handle[^] property - perhaps this will work?

            IntPtr hInstance = System.Diagnostics.Process.GetCurrentProcess().Handle;

            and pass hInstance as the parameter..., I prefer IntPtr.Zero though!

            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
            #17

            I had tested the code above. I feel sorry that it can't work. Because I am developing application for Windows Mobile. The property System.Diagnostics.Process.GetCurrentProcess().Handle can't be get in Mobile. I had try to give hInstance with the value of new IntPtr(GetModuleHandle(new IntPtr(0)).ToInt32()). But when I call lineInitializeEx with it, the return value is an error code. That tell me the value of handle is invalid(0x80000035). Base of all, I think I can't call lineInitializeEx with C# at all. Isn't it?

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

            D 1 Reply Last reply
            0
            • W whiteclouds

              I had tested the code above. I feel sorry that it can't work. Because I am developing application for Windows Mobile. The property System.Diagnostics.Process.GetCurrentProcess().Handle can't be get in Mobile. I had try to give hInstance with the value of new IntPtr(GetModuleHandle(new IntPtr(0)).ToInt32()). But when I call lineInitializeEx with it, the return value is an error code. That tell me the value of handle is invalid(0x80000035). Base of all, I think I can't call lineInitializeEx with C# at all. Isn't it?

              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
              #18

              Have you tried with IntPtr.Zero or new IntPtr(0) What is the error code? It should be one of these:

              /// <summary>
              /// No error.
              /// </summary>
              public const uint LINEERR\_NOERROR = 0x00000000;
              /// <summary>
              /// Invalid application name.
              /// </summary>
              public const uint LINEERR\_INVALAPPNAME = 0x80000015;
              /// <summary>
              /// The INI file is corrupted.
              /// </summary>
              public const uint LINEERR\_INIFILECORRUPT = 0x8000000E;
              /// <summary>
              /// Invalid parameter.
              /// </summary>
              public const uint LINEERR\_INVALPARAM = 0x80000032;
              /// <summary>
              /// Invalid pointer.
              /// </summary>
              public const uint LINEERR\_INVALPOINTER = 0x80000035;
              /// <summary>
              /// No memory available.
              /// </summary>
              public const uint LINEERR\_NOMEM = 0x80000044;
              /// <summary>
              /// The operation failed.
              /// </summary>
              public const uint LINEERR\_OPERATIONFAILED = 0x80000048;
              /// <summary>
              /// The application attempted to initialize TAPI twice.
              /// </summary>
              public const uint LINEERR\_REINIT = 0x80000052;
              

              If the version of WinMob you're targetting supports TAPI then it will work once you get it just right! Maybe post your lineInitializeEx and LINEINITIALIZEEXPARAMS...

              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

                Have you tried with IntPtr.Zero or new IntPtr(0) What is the error code? It should be one of these:

                /// <summary>
                /// No error.
                /// </summary>
                public const uint LINEERR\_NOERROR = 0x00000000;
                /// <summary>
                /// Invalid application name.
                /// </summary>
                public const uint LINEERR\_INVALAPPNAME = 0x80000015;
                /// <summary>
                /// The INI file is corrupted.
                /// </summary>
                public const uint LINEERR\_INIFILECORRUPT = 0x8000000E;
                /// <summary>
                /// Invalid parameter.
                /// </summary>
                public const uint LINEERR\_INVALPARAM = 0x80000032;
                /// <summary>
                /// Invalid pointer.
                /// </summary>
                public const uint LINEERR\_INVALPOINTER = 0x80000035;
                /// <summary>
                /// No memory available.
                /// </summary>
                public const uint LINEERR\_NOMEM = 0x80000044;
                /// <summary>
                /// The operation failed.
                /// </summary>
                public const uint LINEERR\_OPERATIONFAILED = 0x80000048;
                /// <summary>
                /// The application attempted to initialize TAPI twice.
                /// </summary>
                public const uint LINEERR\_REINIT = 0x80000052;
                

                If the version of WinMob you're targetting supports TAPI then it will work once you get it just right! Maybe post your lineInitializeEx and LINEINITIALIZEEXPARAMS...

                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
                #19

                I had try to use the value of IntPtr.Zero and new IntPtr(0) before. The return value is error too. In all cases, the error code returned is still public const uint LINEERR_INVALPOINTER = 0x80000035;. I am sure my Window Mobile support TAPI. I had developed a TAPI application with C++. Thank you!

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

                D 1 Reply Last reply
                0
                • W whiteclouds

                  I had try to use the value of IntPtr.Zero and new IntPtr(0) before. The return value is error too. In all cases, the error code returned is still public const uint LINEERR_INVALPOINTER = 0x80000035;. I am sure my Window Mobile support TAPI. I had developed a TAPI application with C++. Thank you!

                  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
                  #20

                  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 1 Reply Last reply
                  0
                  • 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