![]() |
IInterface Delphi vs VSC
Delphi.
Delphi-Quellcode:
C++
TStreamInfo = record
streamType: TStreamType; ppmt: PAMMEDIATYPE; pdwFlags: Cardinal; plcid: Cardinal; pdwGroup: Cardinal; ppszName: PWideChar; ppObject: IInterface; ppUnk: IInterface; end;
Code:
Bin mir jetzt nicht sicher ob die Übersetzung im Header korrekt ist.
struct TStreamInfo {
TStreamType streamType; AM_MEDIA_TYPE ppmt; unsigned int pdwFlags; unsigned int plcid; unsigned int pdwGroup; wchar_t* ppszName; IUnknown **ppObject; IUnknown **ppUnk; }; C kennt kein IInterface so wie in Delphi oder aber ich finde sie einfach nicht. gruss |
AW: IInterface Delphi vs VSC
IUnknown kennt Delphi auch,
aber fast Egal, da es ein Nachfahre von IInterface ist. Erstmal mußt du auf die Speicherausrichtung achten: Alte Delphis richten Standardmäßig nach "maximal" 4 Byte aus und etwas Neuere nach 8 Byte. Wie im C dort der Standard ist, weiß ich nicht. Also entweder das gleiche Align des C-Compilers explizit für diesen Record oder die ganze Unit einstellen.
Delphi-Quellcode:
{$ALIGN ...}
Oder Packed-Records verwenden. Auf Seite des C auch Packed oder im Delphi mit FüllBytes arbeiten. Speichergrößen: In C++ sind ENUMs/SETs gern so groß wie ein INT und in Delphi so klein wie möglich (meistens Byte und dann Word, LongWord oder UInt64).
Delphi-Quellcode:
{$MINENUMSIZE ...}
|
AW: IInterface Delphi vs VSC
es ging mir um die beiden Einträge.
Code:
ob diese gleichzusetzen sind mit IInterface.
IUnknown **ppObject;
IUnknown **ppUnk; Wenn nicht ist mein Header definitiv falsch übersetzt. gruss |
AW: IInterface Delphi vs VSC
Ja!
|
AW: IInterface Delphi vs VSC
Zitat:
gruss |
AW: IInterface Delphi vs VSC
Zitat:
|
AW: IInterface Delphi vs VSC
Zitat:
War mir nur nicht sicher ob du damit das gleiche gemeint hast. Da steht doch was spätestens dann wenn man eine Quote daraus macht ;) LOL gruss |
AW: IInterface Delphi vs VSC
Zitat aus der System.pas
Zitat:
![]() |
AW: IInterface Delphi vs VSC
Zitat:
So wie das bei IInterface in Delphi ist. also. Ich habe diese Funktionen in der art in meinem Header nicht.
Code:
Wird das in VSC automatisch gemacht wenn ich IUnknown als DatenTyp übergebe?
virtual HRESULT __stdcall QueryInterface(const GUID &IID, void **Obj)
{ return TInterfacedObject::QueryInterface(IID, (void *)Obj); virtual ULONG __stdcall AddRef() { return TInterfacedObject::_AddRef(); } // ... virtual ULONG __stdcall Release() { return TInterfacedObject::_Release(); } gruss |
AW: IInterface Delphi vs VSC
Das ist im IInterface drin.
Bzw. dein Code gehört nicht zum Interface, sondern zur Implementation und da ist es unter Anderem in TInterfacedObject enthalten. |
AW: IInterface Delphi vs VSC
Zitat:
gruss |
AW: IInterface Delphi vs VSC
In Windows (C) können Interfaces scheinbar auch ohne, aber Delphi geht davon aus, dass Interfaces immer mindestens IInterface implementieren. (es wird halt für die automatische Speicherverwaltung verwendet)
|
AW: IInterface Delphi vs VSC
Zitat:
Delphi-Quellcode:
,
_AddRef
Delphi-Quellcode:
und
_Release
Delphi-Quellcode:
bereitstellen.
QueryInterface
Zu beachten ist, dass es unter C++ KEINE automatische Speicherverwaltung gibt. Sprich:
Delphi-Quellcode:
und
_AddRef
Delphi-Quellcode:
muss manuell aufgerufen werden (oder man verwendet den ComPtr). Aber das sollte bei dir keine Probleme machen, da die Implementierung ja in Delphi ist.
_Release
|
AW: IInterface Delphi vs VSC
Zitat:
Darauf wollte ich hinaus ;) gruss |
AW: IInterface Delphi vs VSC
Wenn du es als COM-Interface mit Delphi teilen willst, dann sollte es mit rein. (falls es nicht schon aus einem Vorfahren verwerbt wird)
|
AW: IInterface Delphi vs VSC
Zitat:
|
AW: IInterface Delphi vs VSC
Zitat:
Code:
IUnknown wird von Delphi zurück gegeben.
struct TStreamInfo {
TStreamType streamType; AM_MEDIA_TYPE ppmt; unsigned int pdwFlags; unsigned int plcid; unsigned int pdwGroup; wchar_t* ppszName; IUnknown **ppObject; IUnknown **ppUnk; };
Code:
gruss
BOOL KVIDEOPLAYERDEF(KVideo_GetStreamInfo)(TStreamType StreamType, DWORD index, TStreamInfo OUT StreamInfo);
// Gets informatio for the specified stream // ( parameter ) // - StreamType : type of stream (stAudio, stVideo, stMiscellaneous) // - index : number of rank (first stream = 0) // - StreamInfo : pointer to a TStreamInfo variable // ( result // - true on success, false on failure |
AW: IInterface Delphi vs VSC
Die Frage ist: was machst du mit den beiden IUnknown-Feldern? Solange du die nicht verwendest, sollte es wohl egal sein.
|
AW: IInterface Delphi vs VSC
Zitat:
Und das würde ich später zum vergleich auch in C++ tun.
Delphi-Quellcode:
for i := 0 to aMediaProperty.NumVideoStream - 1 do
begin KVideo_GetStreamInfo(stVideo, i, StreamInfo); menu := TMenuItem.Create(Self); menu.Caption := StreamInfo.ppszName; menu.RadioItem := true; if i = 0 then menu.Checked := true; menu.Tag := i; menu.OnClick := menuVideoStreamClick; menuSelectVideo.Add(menu); end;
Code:
werden dabei aber nicht direkt angesprochen.
IUnknown **ppObject;
IUnknown **ppUnk; gruss |
AW: IInterface Delphi vs VSC
Zitat:
|
AW: IInterface Delphi vs VSC
Zitat:
Danke. gruss |
AW: IInterface Delphi vs VSC
irgendwie will das immer noch nicht.
Code:
Die Rückgabe von..
BOOL KVIDEOPLAYERDEF(KVideo_GetStreamInfo)(TStreamType StreamType, DWORD index, TStreamInfo OUT StreamInfo);
Code:
ist NULL
struct TStreamInfo {
TStreamType streamType; AM_MEDIA_TYPE ppmt; unsigned int pdwFlags; unsigned int plcid; unsigned int pdwGroup; wchar_t* ppszName; IUnknown **ppObject; IUnknown **ppUnk; }; typedef TStreamInfo* pStreamInfo; Hmmm... Ob das mit den Interface doch nicht stimmt? gruss |
AW: IInterface Delphi vs VSC
Da prüft aber auch jemand seine eigenen Rückgabewerte nicht :warn: :-D Ist der Funktionsaufruf am Ende auf Seite der DLL einfach schon nicht erfolgreich?
Ansonsten: Als was ist
Delphi-Quellcode:
definiert? Macro auf
OUT
Delphi-Quellcode:
?
*
|
AW: IInterface Delphi vs VSC
Zitat:
Delphi-Quellcode:
StreamInfo hat alle werte die zur verfügung stehen.
function KVideo_GetStreamInfo(StreamType: TStreamType; index: Cardinal;
out StreamInfo: TStreamInfo): BOOL; stdcall; sie kommen aber in C++ nicht an. [DELPHI]Macro auf * verstehe ich jetzt nicht. Wenn ich die Daten analysiere sind sie vorhanden ich kann sie sehen als ToolTip wenn ich aber durch bin zeigt der ToolTip nix mehr. (Delphi) gruss |
AW: IInterface Delphi vs VSC
In C++ gibt es sowas wie
Delphi-Quellcode:
oder
var
Delphi-Quellcode:
nicht. Hab grade nochmal nachgeschaut: Das
out
Delphi-Quellcode:
Macro aus der Windows.h dient lediglich der Dokumentation und hat im Grunde aber wirklich keine Auswirkung. Du musst alle
OUT
Delphi-Quellcode:
und
var
Delphi-Quellcode:
Parameter in C++ als Pointer umsetzen, also statt
out
Delphi-Quellcode:
muss es
TStreamInfo
Delphi-Quellcode:
bzw.
pStreamInfo
Delphi-Quellcode:
sein:
TStreamInfo*
Delphi-Quellcode:
BOOL KVIDEOPLAYERDEF(KVideo_GetStreamInfo)(TStreamType StreamType, DWORD index, TStreamInfo* StreamInfo);
Der Aufruf entsprechend:
Delphi-Quellcode:
TStreamInfo streamInfo;
KVideo_GetStreamInfo(streamType, index, &streamInfo); |
AW: IInterface Delphi vs VSC
Zitat:
Seltsam aber das es hier funktioniert auch mit OUT.
Code:
Ich denke aber das liegt wohl eher am Pointer *
BOOL KVIDEOPLAYERDEF(KVideo_GetMediaProperty)(TMediaProperty* OUT MediaProperty);
gruss |
AW: IInterface Delphi vs VSC
Zitat:
Delphi-Quellcode:
macht wirklich absolut gar nichts :-D
OUT
|
AW: IInterface Delphi vs VSC
Zitat:
gruss |
AW: IInterface Delphi vs VSC
sollte ich das in Delphi
Delphi-Quellcode:
mit
ppObject: IInterface;
ppUnk: IInterface;
Delphi-Quellcode:
ersetzen oder so belassen.
ppObject: IUnknown;
ppUnk: IUnknown; Weil auch in DirectShow is es als IUnknown definiert. gruss |
AW: IInterface Delphi vs VSC
Zitat:
|
AW: IInterface Delphi vs VSC
Danke ;)
gruss |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:00 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