Undeclared Identifier: 'hWnd'

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
xwerswoodx
Üye
Mesajlar: 1
Kayıt: 05 May 2015 03:54

Undeclared Identifier: 'hWnd'

Mesaj gönderen xwerswoodx »

Merhaba arkadaşlar, mIRC de şifre bilgilerimi gizlemek için bir DLL programı yapmak istiyordum ancak aşağıdaki linkte bulunan dersi takip etmeme rağmen ne yazık ki 2 hata ile karşılaştım, ne kadar arama yapsamda sonuca ulaşamadım, siz değerli abilerimizdn kardeşlerimizden sorunuma cevap olabileceğinizi düşündüm, cevaplayan veya cevaplamayan herkese şimdiden teşekkürler;

Ders: http://delphi.xcjc.net//viewthread.php?tid=46696

Kod:

Kod: Tümünü seç

library Project1;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes;

{$R *.res}
function versionreply( mWnd: hWnd; aWnd: hWnd; Data: PChar; Parms: PChar;
Show: Boolean; NoPause: Boolean ): Integer; export; stdcall;

var blah,blah2:pansichar;

begin
  blah2 := pchar(GetProgramVersion('zirc.dll'));
  blah := pchar('7[14 Zirc.DLL version ' + blah2 + ' 7][14 by Zoomer 7]');
  strcopy(data, blah );
  Result := 3;
end;

exports
versionreply;

begin
end.
Burda hç bir şeyi değiştirmeden ekledim ancak şöyle bir hata ile karşılaştım;

[Error] Project1.dpr(18): Undeclared identifier: 'hWnd'
[Error] Project1.dpr(24): Undeclared identifier: 'GetProgramVersion'

Ne yaptıysam yapayım bu sorunu çözemedim, yardım için teşekkür ederim.
ikra
Üye
Mesajlar: 900
Kayıt: 28 Nis 2005 01:26
Konum: Simdilik Topragin Üstü

Re: Undeclared Identifier: 'hWnd'

Mesaj gönderen ikra »

hwnd windows.pas dosyasinda tanitilmis olmasi gerek (yanilmiyorsam). uses kismina windows yazin.
GetProgramVersion cagirdiginiz bir fonksyon olsa gerek.
DLL'yi yükleyip fonksyonu tanitmaniz gerekir. eger fonksyon adini yazmak istiyorsaniz GetProgramVersion'u tirnak icerisine alip string olarak tanitmaniz icab eder.
kıdemsiz üye
ertank
Kıdemli Üye
Mesajlar: 1653
Kayıt: 12 Eyl 2015 12:45

Re: Undeclared Identifier: 'hWnd'

Mesaj gönderen ertank »

DLL yükleme ile ilgili örnek kod buldum. Paylaşayım:

öncelikle fonksiyon tanıtımı gerekli:

Kod: Tümünü seç


unit rapi;

interface

uses Windows, Sysutils;

TCeRapiInit = function : LongInt stdcall;

function CeRapiInit:LongInt;

implementation

var
  mCeRapiInit : TCeRapiInit;

function RapiLoaded : BOOL;
      {-Assure that TAPI is loaded and globals are set}
begin
      {Load RAPI}
      RapiModule := LoadLibrary('RAPI.DLL');

      if RapiModule >   HINSTANCE_ERROR then
      begin
          {Say it's loaded...}
          Result := True;

          {...and load all globals}
          @mCeRapiInit := GetProcAddress(RapiModule, 'CeRapiInit');
      end else
        Result := False;
end;

function CeRapiInit : LongInt;
      {-Initialize a line device}
begin
      if not RapiLoaded then begin
          Result := $FFFF;
          Exit;
      end;

      if @mCeRapiInit < >   nil then
          Result := mCeRapiInit
      else
          Result := $FFFF;
end;

Cevapla