Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi Problem beim einbinden einer in c geschrieben dll (https://www.delphipraxis.net/176385-problem-beim-einbinden-einer-c-geschrieben-dll.html)

blinder007 1. Sep 2013 14:29

Datenbank: dll • Version: keine • Zugriff über: delphi 6

Problem beim einbinden einer in c geschrieben dll
 
Liste der Anhänge anzeigen (Anzahl: 1)
hallo Community,
der Fehler "procedureinsprungspunkt nicht gefunden", ist allseits bekannt und nun überfiel er auch mich. Nur ich sehe mich außerstande ihn zu beheben.
Im Anhang befindet sich die DLL "Screenreaderapi.dll" mit der ich arbeiten möchte, zusätzl. weiterer dateien zur programmierung in c und anderen sprachen. beim statischen einbinden der dll erhalte ich nur diesen Fehler.
Mein vorgehen war folgendes: Ich wandelte die dll, welche in c geschreiben wurde, in eine delphi unit, um an die namen und parameter der dll zu gelangen. Ich probierte nun eine function aus, indem ich über
function "functionsname"(parameter): rückgabewert; stcall; external 'screenreaderapi.dll' (es handelte sich dabei um die function saystring)
diese einband. das risultat war der bekannte fehler. beim dynamischen einbinden traten ebenfalls fehler auf. Hier sagte mir der kompiler "Function braucht einen rückgabewert", dieser war jedoch vorhanden.
Ich bitte um hilfe, da diese dll essenziel für die entwicklungmeines programmes ist. bei fragen oder anderen Hinweisen, bitte schreibt dies, da ich nicht genau weiß, was noch an informationen benötigt werden, um mir zu helfen
grüße
Blinder007

sx2008 1. Sep 2013 17:42

AW: Problem beim einbinden einer in c geschrieben dll
 
Wieso verwendest du nicht die angebotene COM/DCOM-Schnittstelle?
Einfach den Anweisungen in readme.txt "2.3. Using the COM interface" folgen.
Dann in Delphi unter Projekt -> Typbibliothek importieren die Typbibliothek "Screen reader API COM Server 1.0" einlesen.
Durch das Importieren der TLB vermeidest du alle Fehler die ggf. beim Übersetzen von C-Headerfiles nach Delphi auftreten können.
Und dann so benützen:
Delphi-Quellcode:
var
  x : OleVariant;
begin
  x := CreateOleObject('ScreenReaderAPI.Interface');
  x.SapiEnable(true);
  x.SayString('hello world', true);
  // ungetestet - bitte selber weiterforschen
Zusatzinfo, falls du dennoch die C-Funktionen verwenden willst:
1.) die Funktionsnamen sind case-sensitive; d.h. es kommt auf die Groß-/Kleinschreibung an.
Ein falscher Buchstabe und der Fehler "procedureinsprungspunkt nicht gefunden" kommt zum Vorschein.
2.) um genau zu untersuchen welche Funktionen in einer DLL sind eignet sich das Programm Dependency Walker. (sehr nützliches Tool das zur Grundausstattung jedes Windows Programmierers gehört)

Horst0815 1. Sep 2013 18:27

AW: Problem beim einbinden einer in c geschrieben dll
 
hab nicht alles übersetzt

Delphi-Quellcode:
unit ScreenreaderAPI;

interface

uses WinAPI.Windows;

Const dllname = 'ScreenReaderAPI.dll';

// Global functions. These should be used preferably to the specific ones so
// that you are independent of the screen reader used by the end user.
// Speak a string of text and tell if currently speaking text should
// be interrupted or not.
// With true as second argument, the given string of text is immediately
// speaking, interrupting what was speaking before
// With false, the given string is appended to the queue of messages to speak,
// the current message being spoken is not interrupted

Function sayStringA( a : PAnsiChar; interrupt : Boolean):Boolean; stdcall; external dllname;
// unicode version of the function above */
Function sayStringW( a : PWideChar; interrupt : Boolean):Boolean; stdcall; external dllname;

// Immediately stops any spoken text
Function stopSpeech:Boolean; stdcall; external dllname;

// Show a message on the braille display.
Function brailleMessageA( a : PAnsiChar):Boolean; stdcall; external dllname;
Function brailleMessageW( a : PWideChar):Boolean; stdcall; external dllname;

// Tell or define which scrren reader is currently used by the global functions
// above. See SR_* constants for values meaning
// Since integer identifiers are subject to change, you are recommended to
// use getCurrentScreenReaderName instead of this function.

Function getCurrentScreenReader:Integer; stdcall; external dllname;
Function setCurrentScreenReader (screenReaderID : Integer):Integer; stdcall; external dllname;

// Get or set the current screen reader using a screen reader name.
// Don't try to free the strings returned, they are statically defined
// inside the library.


Function getCurrentScreenReaderNameA:PAnsiChar; stdcall; external dllname;
Function getCurrentScreenReaderNameW:PWideChar; stdcall; external dllname;

Function setCurrentScreenReaderNameA (const name : PAnsiChar):Integer; stdcall; external dllname;
Function setCurrentScreenReaderNameW (const name : PWideChar):Integer; stdcall; external dllname;

// Retriev the name from the id or the id from the name of a screen reader
// Don't try to free the strings returned, they are statically defined
// inside the library.

Function getScreenReaderNameA (id : Integer):PAnsiChar; stdcall; external dllname;
Function getScreenReaderNameW (id : Integer):PWideChar; stdcall; external dllname;
Function getScreenReaderIdA (const name : PAnsiChar):Integer; stdcall; external dllname;
Function getScreenReaderIdW (const name : PWideChar):Integer; stdcall; external dllname;

// Get the number of engines supported
Function getSupportedScreenReadersCount:Integer; stdcall; external dllname;

// Tell or define if SAPI5 must be used as fallback if no any other screen
// reader is found. Default is FALSE.
Function sapiIsEnabled:Boolean; stdcall; external dllname;
Function sapiEnable (enable: Boolean):Boolean; stdcall; external dllname;

// SAPI5 specific functions

// unload SAPI5 engine. */
Function sapiLoad:Boolean; stdcall; external dllname;
Procedure sapiUnload; stdcall; external dllname;
///** Say functions. SSML variants accept XML tags as defined by Microsoft Speech Synthesis Markup Language. Other variants only accept plain text. */
Function sapiSayStringW (const str : PWideChar; interrupt : Boolean):Boolean; stdcall; external dllname;
Function sapiSaySSMLW (const str : PWideChar; interrupt : Boolean):Boolean; stdcall; external dllname;
// See MSDN if you want to work with SSML speech synthesis markup language
Function sapiSayStringA (const str : PAnsiChar; interrupt : Boolean):Boolean; stdcall; external dllname;
Function sapiSaySSMLA (const str : PAnsiChar; interrupt : Boolean):Boolean; stdcall; external dllname;
Function sapiStopSpeech:Boolean; stdcall; external dllname;
// Set speech rate between 0 (slowest) to 100 (fastest). 50=middle.
Function sapiSetRate (rate´: Integer):Boolean; stdcall; external dllname;
// Return current speech rate between 0 and 100, negative on error or if that information is unavailable */
Function sapiGetRate:Integer; stdcall; external dllname;
// Set the speech volume between 0 (quietest) to 100 (loudest)
Function sapiSetVolume (volume : Integer):Boolean; stdcall; external dllname;
// Return the current speech volume between 0 and 100, negative on error or if that information is unavailable */
Function sapiGetVolume:Integer; stdcall; external dllname;
// Tell or set the pause status of the speech
FUnction sapiSetPaused (paused : Boolean):Boolean; stdcall; external dllname;
Function sapiIsPaused:Boolean; stdcall; external dllname;
// Wait for SAPI to complete its speech up to the specified number of milliseconds.
Function sapiWait (timeout : Integer):Boolean; stdcall; external dllname;
// Tell if SAPI is currently speaking
Function sapiIsSpeaking:Boolean; stdcall; external dllname;
// Return the number of SAPI voices availables in the system
Function sapiGetNumVoices:Integer; stdcall; external dllname;
// SEt the speaking voice, use 0-based index */
Function sapiSetVoice (n : Integer):Boolean; stdcall; external dllname;
// Return the 0-based index of the current SAPI voice used, -1 for default, <=-2 on error or if that information is unavailable. */
Function sapiGetVoice:Integer; stdcall; external dllname;
// Return the name of the nth voice.
// Strings returned by this function must be free when no longer used.
Function sapiGetVoiceNameW (n : Integer):PWideChar; stdcall; external dllname;
///* ANSI version of the function above. Returned strings must be free when no longer used. */
Function sapiGetVoiceNameA (n : Integer):PAnsiChar; stdcall; external dllname;

// Misc functions
//  Install or uninstall a keyboard hook. CAn be used to bypass jaws keyboard
// hook, but it may not always work.
// Don't forget to uninstall on exit. You should also consider uninstalling
// it when the user switch to another application
// (by using Alt+Tab for example), and reinstall it again when the user
// come back to your application, so that other applications behave normally.
Function installKeyboardHook:Boolean; stdcall; external dllname;
Procedure uninstallKeyboardHook;stdcall; external dllname;


implementation

end.


Aufruf mit
Delphi-Quellcode:
procedure TForm4.Button1Click(Sender: TObject);
begin
sapiLoad;
sapiSayStringA('Ich bin ein Test', true);
sapiWait(-1);
end;

Luckie 1. Sep 2013 21:44

AW: Problem beim einbinden einer in c geschrieben dll
 
Was hat das mit Datenbanken zu tun? Ich frage mal nach, bevor ich es verschiebe.


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:10 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 by Thomas Breitkreuz