![]() |
AW: is a 'field' but is used like a 'type'
Sorry aber was soll das jetzt. ?
Ich weiß was eine Klasse ein Feld und eine Methode ist. Meinen Fehler immer wieder zu posten bringt einfach nichts. Es ist mir bekannt das es falsch ist. Und wie schon gesagt höchstwahrscheinlich so wie in Delphi/C++ nicht umsetzbar. Wenn doch wie ist die Lösung. ? gruss |
AW: is a 'field' but is used like a 'type'
Zitat:
Zur Erinnerung (ist wohl schon zu lange her) Zitat:
|
AW: is a 'field' but is used like a 'type'
Die beste Lösung wäre wohl:
Zitat:
Zitat:
|
AW: is a 'field' but is used like a 'type'
Die beste Lösung wäre einfach, keine Synonyme für Typen zu verwenden. Das verwirrt doch nur.
|
AW: is a 'field' but is used like a 'type'
Zitat:
Ich wollte halt die API so auslegen wie es in C++/Delphi ist, geht aber wohl nicht. Ist halt nicht überall Konform abhängig von der Developer Sprache halt. Ich habe es nun mit IntPtr gemacht. Zitat:
gruss |
AW: is a 'field' but is used like a 'type'
C-Sprachen sind case-sensitive, d.h. HTAGS != HTags
|
AW: is a 'field' but is used like a 'type'
Zitat:
Hat aber nichts mit meinem Problem zu tun. gruss |
AW: is a 'field' but is used like a 'type'
Was Sir Rufo meinte ist, dass du eine Variable (bzw. ein Feld) in der Klasse vom Typ IntPtr mit dem Namen HTags erstellt.
Die Funktion sollte aber den Typ HTAGS zurückgeben. Deshalb wohl auch die Anmerkung von Sailor. Zitat:
Code:
Man beachte das groß geschriebene HTAGS. Aber schlag mich bitte nicht, wenn das nicht so funktioniert wie gewünscht. Bin auch kein C#/C++ Profi. Habs mir nur mal für ein kleineres Projekt angesehen.
public static extern HTAGS TagsLibrary_Create();
Dein HTAGS Typ solltest du dir dann so einbauen können.
Code:
typedef IntPtr HTAGS
Stimmt, in C# gibt es ja gar kein Typdef :shock: Vielleicht hilft es ja trotzdem weiter. :roll: |
AW: is a 'field' but is used like a 'type'
Zitat:
Sie muss identisch mit dem Definierten Name sein. (Groß und Kleinschreibung beachtend) Wenn als
Code:
definiert muss sie auch in folge so benannt werden.
IntPtr HtAgS = IntPtr.Zero;
Aber das merkt der Compiler da muss man sich selbst nicht drum kümmern. Zitat:
Code:
Genau so hab ich es gemacht.
public static extern HTAGS TagsLibrary_Create();
Code:
HTags = HTags
IntPtr HTags = IntPtr.Zero;
public static extern HTags TagsLibrary_Create(); HTAGS = HTAGS HTAGS = HTags geht nicht.. Was ich aber schon sagte (Ist mir bekannt) gruss |
AW: is a 'field' but is used like a 'type'
Letztendlich habe ich die Lösung dann doch selbst noch erarbeitet (nicht aus dem Internet)
Code:
Jetzt geht das!
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct HTAGS { private IntPtr _htags; public IntPtr HTags { get { return _htags; } set { _htags = value; } } }
Code:
und das! (Darum ging es mir.. Die API gleich zu halten mit den Aufruf Konventionen.
//TagsLibrary_Create
[DllImport("TagsLib.dll", EntryPoint = "TagsLibrary_Create", CharSet = CharSet.Auto)] public static extern HTAGS TagsLibrary_Create();
Code:
in der Anwendung wird dann einmalig HTAGS definiert.
//TagsLibrary_Free
[return: MarshalAs(UnmanagedType.Bool)] [DllImport("TagsLib.dll", EntryPoint = "TagsLibrary_Free", CharSet = CharSet.Auto)] public static extern bool TagsLibrary_Free(HTAGS Tags);
Code:
Dim hTags As HTAGS
Code:
In Delphi ist der Aufruf wie folgt!
hTags = TagsLib.TagsLibrary_Create()
If TagsLib.TagsLibrary_Free(hTags) Then MessageBox.Show("Is Free") End If
Delphi-Quellcode:
t_TagsLibrary_Free = function (Tags: HTags): LongBool; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
Und genau diese Art des Aufrufs wollte ich beibehalten Tags: HTags Deshalb schreibe ich die Lib (Wrapper in C#) damit Developer mit VB_NET sich mit der API nicht rumquälen müssen. gruss |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:36 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