AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Parameterprobleme beim Aufruf einer Delphi DLL aus C#
Thema durchsuchen
Ansicht
Themen-Optionen

Parameterprobleme beim Aufruf einer Delphi DLL aus C#

Ein Thema von JonnyGuitar · begonnen am 26. Okt 2009 · letzter Beitrag vom 28. Okt 2009
 
JonnyGuitar

Registriert seit: 4. Jun 2004
233 Beiträge
 
#8

Re: Parameterprobleme beim Aufruf einer Delphi DLL aus C#

  Alt 27. Okt 2009, 11:18
Hallo,

das holen der IMapiSession wird unterstützt.
Ich habe hier ein Beispiel in C++ von CodeProject was funktioniert:

Delphi-Quellcode:
String^ Fabric::GetProfileName(Object^ mapiObject)
   {

      // the result returned to the calling method
      String^ result = nullptr;

      // pointer to IUnknown interface
      IUnknown* pUnknown = 0;

      // pointer to the MAPI session interface
      LPMAPISESSION lpMAPISession = 0;

      // pointer to a profilesection interface
      LPPROFSECT lpProfileSection = 0;

      // pointer to a structure that receives the result from HrGetOneProp
      LPSPropValue lpSPropValue = 0;

      // if we have no MAPIObject everything is senseless...
      if (mapiObject == nullptr)
         throw gcnew System::ArgumentNullException ("mapiObject","The MAPIObject must not be null!");

      try
      {
         // retrive the IUnknon Interface from our MAPIObject comming from Outlook.
         pUnknown = (IUnknown*)Marshal::GetIUnknownForObject(mapiObject).ToPointer ();
         
         // try to retrieve the IMAPISession interface, if we don't get it, everything else is sensless.
         if ( pUnknown->QueryInterface (IID_IMAPISession, (void**)&lpMAPISession) != S_OK)
            throw gcnew Exception("QueryInterface failed on IUnknown for IID_IMAPISession");
                    
         // use the OpenProfileSection of the MAPISession object to retrieve a pointer to the current profilesection interface
         if( lpMAPISession->OpenProfileSection((LPMAPIUID)GLOBAL_PROFILE_SECTION_MAPIUID ,NULL,STGM_READ, &lpProfileSection) != S_OK)
           throw gcnew Exception("OpenProfileSection method failed!");

         // use the HrGetOneProp method to retrieve the profile name property
         // the lpPropValue pointer points to the result value
         if (HrGetOneProp(lpProfileSection,PR_PROFILE_NAME_W,&lpSPropValue) != S_OK)
            throw gcnew Exception("HrGetOneProp failed for property PR_PROFILE_NAME_W !");
         
         // create a managed string from the unmanaged string.
         return gcnew String(  lpSPropValue->Value.lpszW );

      }

      catch (Exception^ ex)
      {
         // if an error occures get the MAPI error code
         DWORD dw = GetLastError();
         
         // and translate it into a human readable message
         if (dw != 0) throw gcnew Exception(GetErrorText(dw),ex);
         
         throw ex;
      }

      finally
      {
         // Free buffer allocated by MAPI
         if (lpSPropValue != 0) MAPIFreeBuffer(lpSPropValue);

         // cleanup all references to MAPI Objects
         if (lpProfileSection!=0) lpProfileSection->Release();
         if (lpMAPISession!=0) lpMAPISession->Release();
         if (pUnknown!=0) pUnknown->Release();
      }

   }
Das IUnknown kommt auch nach meiner Erkenntnis richtig in Delphi an, zumindest das Handle stimmt in C# und Delphi
überein. Das QueryInterface liefert den Mapi Fehler: MAPI_E_CALL_FAILED
In C++ klappt es komischerweise


Gruss Jonny
the only thing to fear is runnin' out of beer
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:38 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz