Autor Beitrag
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 27.09.05 06:51 
Ist es eigentlich möglich eine Win32-DLL (von Delphi) in eine .NET-Anwendung einzubinden? Ich und ein anderer haben es schon versucht, sind aber bisher gescheitert. Wenn es geht, könnt ihr mir dann auch sagen wie es geht?


Moderiert von user profile iconraziel: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Di 27.09.2005 um 11:23
Moderiert von user profile iconChristian S.: Topic aus .NET verschoben am Di 27.09.2005 um 18:19
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 27.09.05 11:24 

_________________
Ciao, Sprint.
Heiko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 27.09.05 18:07 
Zitat:
We’re sorry, we were unable to service your request. As an option, you may visit any of the pages below for information about Microsoft services and products.


Der Link fürht also scheinbar ins Nirvana ;).
MagicAndre1981
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 27.09.05 18:10 
Hier ist der richtige Link:

msdn.microsoft.com/l...llingWindowsAPIs.asp

André
Heiko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 27.09.05 18:16 
Ich habe es gerade mal angelesen. Es scheint mir bisher so, als ob es nur .NET hier betrifft. Muss ich unter Delphi auch noch etwas beachten?
Marauder
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 72



BeitragVerfasst: So 02.10.05 13:30 
so geht das mit der DLL
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
unit WinForm;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,System.Text,
  System.Windows.Forms, System.Data,projekt1,System.Runtime.InteropServices;

  [DLLImport ('User32')]
  Function CharUpperA (lpResult:StringBuilder): Integer;external;


Wichtig ist das Einbinden der Interop-Services und das Verwenden des Attributes DLLImport.
Robert_G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416


Delphi32 (D2005 PE); Chrome/C# (VS2003 E/A, VS2005)
BeitragVerfasst: So 02.10.05 14:56 
user profile iconMarauder hat folgendes geschrieben:
der Interop-Services und das Verwenden des Attributes DLLImport.

Naja, er fragte nicht für Delphi.Net und somit kann er aber muss nicht den namespace in die Imports clause aufnehmen.
ausblenden Beispiel aus der SDK Doku um den inline namespace ergänzt:
1:
2:
3:
4:
5:
6:
7:
8:
<System.Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint := "MoveFileW", _
   SetLastError := True, CharSet := CharSet.Unicode, _
   ExactSpelling := True, _
   CallingConvention := CallingConvention.StdCall)> _
Public Shared Function MoveFile(src As String, dst As String) As Boolean
    ' Leave function empty - DLLImport attribute forwards calls to MoveFile to
    ' MoveFileW in KERNEL32.DLL.
End Function

Auch wenn es Jahre an harter Arbeit gekostet hat, VB.Net noch hässlicher als VB zu machen, es verhält sich wenigstens wie eine normale .Net Sprache. ;)

@Heiko
Für mehr Infos einfach das VS bzw die SDK Doku öffnen und nach DllImportAttribute suchen.