private static IntPtr PKStr2PKPtr(PRE_PK pk)
        {
            PRE_ptrPK ptrPK = new PRE_ptrPK
            {
                pk1 = Marshal.StringToHGlobalAnsi(pk.PK1),
                pk2 = Marshal.StringToHGlobalAnsi(pk.PK2)
            };
            IntPtr pPk = Marshal.AllocHGlobal(Marshal.SizeOf(ptrPK));

            Marshal.StructureToPtr(ptrPK, pPk, true);
            return(pPk);
        }
        private static IntPtr KeyStr2KeyPtr(PRE_KEY key)
        {
            PRE_ptrPK ptrPK = new PRE_ptrPK {
                pk1 = Marshal.StringToHGlobalAnsi(key.PK.PK1), pk2 = Marshal.StringToHGlobalAnsi(key.PK.PK2)
            };
            IntPtr pPk = Marshal.AllocHGlobal(Marshal.SizeOf(ptrPK));

            Marshal.StructureToPtr(ptrPK, pPk, true);

            PRE_ptrSK ptrSK = new PRE_ptrSK {
                x1 = Marshal.StringToHGlobalAnsi(key.SK.X1), x2 = Marshal.StringToHGlobalAnsi(key.SK.X2)
            };
            IntPtr pSk = Marshal.AllocHGlobal(Marshal.SizeOf(ptrSK));

            Marshal.StructureToPtr(ptrSK, pSk, true);

            PRE_ptrKEY keyPtr = new PRE_ptrKEY {
                pk = pPk, sk = pSk
            };
            IntPtr pKey = Marshal.AllocHGlobal(Marshal.SizeOf(keyPtr));

            Marshal.StructureToPtr(keyPtr, pKey, true);
            return(pKey);
        }
 private static IntPtr PKStr2PKPtr( PRE_PK pk )
 {
     PRE_ptrPK ptrPK = new PRE_ptrPK
     {
         pk1 = Marshal.StringToHGlobalAnsi( pk.PK1 ) ,
         pk2 = Marshal.StringToHGlobalAnsi( pk.PK2 )
     };
     IntPtr pPk = Marshal.AllocHGlobal( Marshal.SizeOf( ptrPK ) );
     Marshal.StructureToPtr( ptrPK , pPk , true );
     return pPk;
 }
        private static IntPtr KeyStr2KeyPtr( PRE_KEY key )
        {
            PRE_ptrPK ptrPK = new PRE_ptrPK { pk1 = Marshal.StringToHGlobalAnsi( key.PK.PK1 ) , pk2 = Marshal.StringToHGlobalAnsi( key.PK.PK2 ) };
            IntPtr pPk = Marshal.AllocHGlobal( Marshal.SizeOf( ptrPK ) );
            Marshal.StructureToPtr( ptrPK , pPk , true );

            PRE_ptrSK ptrSK = new PRE_ptrSK { x1 = Marshal.StringToHGlobalAnsi( key.SK.X1 ) , x2 = Marshal.StringToHGlobalAnsi( key.SK.X2 ) };
            IntPtr pSk = Marshal.AllocHGlobal( Marshal.SizeOf( ptrSK ) );
            Marshal.StructureToPtr( ptrSK , pSk , true );

            PRE_ptrKEY keyPtr = new PRE_ptrKEY { pk = pPk , sk = pSk };
            IntPtr pKey = Marshal.AllocHGlobal( Marshal.SizeOf( keyPtr ) );
            Marshal.StructureToPtr( keyPtr , pKey , true );
            return pKey;
        }