Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

Need help with MarshalAs with custom data structure/enum

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pucca - 30 Aug 2006 01:07 GMT
I have the following C++ function exported.  The returned type is a typedef
enum and the 2nd parm passed in is a class type that I defined.
How do I declare the marshalas for the parm and how do I deal with the
return type?  Thanks.

------------------------------------------------------
extern "C" DE_ERRORS __declspec(dllexport)DecodeAsnUser(Blob* pBlob,
CUserContextData *userData)
{
   My Code;
}
---------------------------------------------------------
typedef enum
{
    DE_SUCCESS,
    DE_CONNECTION_LOST,
    DE_UNKNOWN_REQUEST,
    DE_UNKNOWN_LIBRARY,
    DE_UNKNOWN_MSG_VERSION,
    DE_MSG_SEQ_ERROR,
    DE_MEMORY_ALLOCATION_FAILURE,
    DE_ENCODE_MESSAGE_PACKET_FAILURE,
    DE_EXTRACT_MESSAGE_FAILURE,
    DE_SELECT_FAILURE,
    DE_SEND_PACKET_FAILURE,
    DE_BAD_SOCKET,
    DE_RECEIVE_PACKET_FAILURE,
    DE_TRUNCATED_LENGTH_RECEIVED,
    DE_SOCKET_FAILURE,
    DE_FIFO_EMPTY,
    DE_RESPONSE_TIMEOUT,
    DE_LOAD_LIBRARY_FAILURE,
    DE_THREAD_CREATION_FAILURE,
    DE_NULL_SERVER_FUNCTION_TABLE,
    DE_NULL_CLIENT_FUNCTION_TABLE,
    DE_REASSIGNING_CLIENT_FUNCTION_TABLE,
    DE_FIFO_CONDITION_WAIT_FAILURE,
    DE_FIFO_TAIL_IS_NULL_ON_FETCH,
    DE_SIGNAL_THREAD_FAILURE,
    DE_BAD_ARGUMENTS,
    DE_BUFFER_EXHAUSTED,
    DE_RWLOCK_INITIALIZATION_FAILURE,
    DE_WRITE_LOCK_FAILURE,
    DE_READ_LOCK_FAILURE,
    DE_RELEASE_LOCK_FAILURE,
    DE_MUTEX_INITIALIZATION_FAILURE,
    DE_INDEX_INSERT_FAILURE,
    DE_INVALID_ENTRY_TYPE,
    DE_WAITING_CONDITION_FAILURE,
    DE_UNABLE_TO_ACQUIRE_ADS_CONNECTION,
    DE_ROW_INSERT_FAILURE,
    DE_UPDATE_MESSAGE_POST_FAILURE,
    DE_MUTEX_LOCK_FAILURE,
    DE_MUTEX_UNLOCK_FAILURE,
    DE_UNABLE_TO_CREATE_TEMPORARY_ROW,
    DE_UNABLE_TO_GET_USER_LIST_FROM_AD,
    DE_UNABLE_TO_GET_GROUP_LIST_FROM_AD,
    DE_UNABLE_TO_OPEN_CONFIGURATION_FILE
} DE_ERRORS;
-------------------------------------------------------------------------
class CUserContextData
{
public:
       
   bool newObject, bWinLogOn, bUnifiedID, symarkEnabled, UIDChanged,
newSyUserContext, NoChanged,
        saved;
    std::wstring SID, shell, homeDir, primaryGroup, symarkUserRef, LoginName,
contextName, groupCN;
   int symarkUID, //Unified User ID
        IID,       //Independant ID
        listViewIndex, groupIndex;

//operator= Overload function
    CUserContextData& CUserContextData::operator=(const CUserContextData&
newUserData)
    {
        if(this != &newUserData)
        {
        newObject = newUserData.newObject;
        bWinLogOn = newUserData.bWinLogOn;
        bUnifiedID = newUserData.bUnifiedID;
        symarkEnabled = newUserData.symarkEnabled;
        UIDChanged = newUserData.UIDChanged;
        newSyUserContext = newUserData.newSyUserContext;
        NoChanged = newUserData.NoChanged;
        saved = newUserData.saved;
        symarkUID = newUserData.symarkUID;
        listViewIndex = newUserData.listViewIndex;
        IID = newUserData.IID;
        groupIndex = newUserData.groupIndex;
           
        contextName = newUserData.contextName;
        groupCN = newUserData.groupCN;
           
        LoginName = newUserData.LoginName;

        shell = newUserData.shell;

        homeDir = newUserData.homeDir;

        primaryGroup = newUserData.primaryGroup;

        symarkUserRef = newUserData.symarkUserRef;
        SID = newUserData.SID;
        }
        return *this;
}//End operator= Overload

//Copy Constructor
CUserContextData::CUserContextData(const CUserContextData &nud)
  :  newObject(nud.newObject), bWinLogOn(nud.bWinLogOn),  
bUnifiedID(nud.bUnifiedID),
  symarkEnabled(nud.symarkEnabled),
UIDChanged(nud.UIDChanged),shell(nud.shell),
 
newSyUserContext(nud.newSyUserContext),NoChanged(nud.NoChanged),saved(nud.saved),
  SID(nud.SID), homeDir(nud.homeDir), primaryGroup(nud.primaryGroup),
  symarkUserRef(nud.symarkUserRef), LoginName(nud.LoginName),
  contextName(nud.contextName), groupCN(nud.groupCN),
symarkUID(nud.symarkUID),
  listViewIndex(nud.UIDChanged), IID(nud.IID), groupIndex(nud.groupIndex)

{
}

//Default Constructor
CUserContextData::CUserContextData(void) :  newObject(false),
bWinLogOn(false),  bUnifiedID(false),
    symarkEnabled(false), UIDChanged(false), newSyUserContext(false),
NoChanged(false),
    saved(false), symarkUID(0), listViewIndex(0), IID(0), groupIndex(-1)

{
}

~CUserContextData(void)
{
}

};
------------------------------------------------------------------
Signature

Thanks.

Pucca - 30 Aug 2006 02:05 GMT
Ok, forget the class type.  I think it would be easier to pass in and out a
structure.  Here is my declaration in my C++

    struct CUserContextData
    {
         bool bWinLogOn, bUnifiedID, symarkEnabled;
         std::wstring shell, homeDir, primaryGroupSID, symarkUserRef,
              LoginName, contextName, groupCN;
         int symarkUID, //Unified User ID
              IID,       //Independant ID
              Revision, groupIndex;
    } pCUserContextData;
Signature

Thanks.

> I have the following C++ function exported.  The returned type is a typedef
> enum and the 2nd parm passed in is a class type that I defined.
[quoted text clipped - 138 lines]
> };
> ------------------------------------------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.