Hallo Leute,

ich muss für ein intranet programm (asp.net mit c#) auf eine dll zugreifen mit deren hilfe man auf eine fremde datenbank user anlegen kann usw. ich habe auch eine beispiel dafür gefunden wie man das machen kann, jedoch ist diese beispiel (siehe unten) in c++ geschrieben. kann jemand mir helfen und erklären, wie man das in c# macht? Danke im Voraus

 

mfg bas

 

Example 1: Creating a new user account

As an example, we will try to insert a new user ”mary” into OmniTracker’s database.

  • Create a new dialog-based project using the ”MFC AppWizard (exe)”.

  • Add a button called ”Add User” to the dialog.

  • Assign a handler OnAddUser() to the button, and fill it with the following code:

IOtApplicationPtr pApp;

HRESULT hr = pApp.CreateInstance(__uuidof(OtApplication), NULL,

CLSCTX_INPROC_SERVER);

if (FAILED(hr))

{

CString str;

str.Format ("CreateInstance() failed: 0x%08lx",

   (ULONG) hr);

AfxMessageBox (str);

}

try {

IOtSessionPtr pSession;

pSession = pApp->MakeSession("hostname", 4567,

"superuser", "password");

 

IOtUsersPtr pUsers;

pUsers = pSession->Users;

 

IOtUserPtr pUser;

pUser = pUsers->Add();

 

pUser->LoginName = "mary";

pUser->EmailAddress = "[EMAIL PROTECTED]";

pUser->Password = "65gh45";

pUser->DisplayName = "Mary";

pUser->Save();

 

} catch(_com_error& e) {

_bstr_t bstrDescription(e.Description());

AfxMessageBox((LPCTSTR) bstrDescription);

}

 
  • At the top of the file containing OnAddUser(), add the following line:

#import "otaut.tlb" no_namespace

This imports the definitions from the OmniTracker Automation interface.

  • Make sure, that the OmniTracker installation directory is part of the list of the C++ preprocessor ‘s include directories.

  • In the InitInstance() routine of your application, initialize COM by including the following lines:

HRESULT hr = CoInitialize(NULL);

if (FAILED(hr))

{

AfxMessageBox ("Cannot initialize COM!");

return FALSE;

}

 

  • Compile and link the source files, and execute the program.

Antwort per Email an