Q&A

  • 이런 에러는 어케 잡아요. 정말 못잡겠어요..
* 사용환경 : 델파이4 / Windows 98

* 에러 메시지 :





[Error] Unit1.pas(47): Types of actual and formal var parameters must be identical

[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'





unit Unit1;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, WinSvc;



type

TForm1 = class(TForm)

Button1: TButton;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

function ServiceStartStatus(sService : string ) : DWord;

public

{ Public declarations }

end;



var

Form1: TForm1;



implementation



{$R *.DFM}





procedure TForm1.Button1Click(Sender: TObject);

begin

showmessage(IntToStr(ServiceStartStatus('ServiceServerDemon')));

end;



// 리턴값이 0이면 에러, 1이면 자동실행, 2이면 수동실행이다.

function TForm1.ServiceStartStatus(sService : string ) : DWord;

var

schm, schs : SC_Handle;

ss : TQueryServiceConfig;

dwStat, temp : Integer;

begin

dwStat := 0;

schm := OpenSCManager(Nil,Nil,SC_MANAGER_CONNECT);

if(schm > 0)then

begin

schs := OpenService(schm,PChar(sService),SERVICE_QUERY_CONFIG);

if(schs > 0)then

begin

if QueryServiceConfig(schs,ss,SizeOf(ss),temp) then dwStat := ss.dwStartType;

CloseServiceHandle(schs);

end;

CloseServiceHandle(schm);

end;



if SERVICE_AUTO_START = dwStat then

dwStat := 1;



if SERVICE_DEMAND_START = dwStat then

dwStat := 2;



Result := dwStat;

end;



end.





1  COMMENTS
  • Profile
    psh 2000.05.28 21:46
    황당이 wrote:

    > * 사용환경 : 델파이4 / Windows 98

    > * 에러 메시지 :

    >

    >

    > [Error] Unit1.pas(47): Types of actual and formal var parameters must be identical

    > [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

    >

    >

    > unit Unit1;

    >

    > interface

    >

    > uses

    > Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

    > StdCtrls, WinSvc;

    >

    > type

    > TForm1 = class(TForm)

    > Button1: TButton;

    > procedure Button1Click(Sender: TObject);

    > private

    > { Private declarations }

    > function ServiceStartStatus(sService : string ) : DWord;

    > public

    > { Public declarations }

    > end;

    >

    > var

    > Form1: TForm1;

    >

    > implementation

    >

    > {$R *.DFM}

    >

    >

    > procedure TForm1.Button1Click(Sender: TObject);

    > begin

    > showmessage(IntToStr(ServiceStartStatus('ServiceServerDemon')));

    > end;

    >

    > // 리턴값이 0이면 에러, 1이면 자동실행, 2이면 수동실행이다.

    > function TForm1.ServiceStartStatus(sService : string ) : DWord;

    > var

    > schm, schs : SC_Handle;

    > ss : TQueryServiceConfig;

    > dwStat, temp : Integer;

    > begin

    > dwStat := 0;

    > schm := OpenSCManager(Nil,Nil,SC_MANAGER_CONNECT);

    > if(schm > 0)then

    > begin

    > schs := OpenService(schm,PChar(sService),SERVICE_QUERY_CONFIG);

    > if(schs > 0)then

    > begin

    > if QueryServiceConfig(schs,ss,SizeOf(ss),temp) then dwStat := ss.dwStartType;

    > CloseServiceHandle(schs);

    > end;

    > CloseServiceHandle(schm);

    > end;

    >

    > if SERVICE_AUTO_START = dwStat then

    > dwStat := 1;

    >

    > if SERVICE_DEMAND_START = dwStat then

    > dwStat := 2;

    >

    > Result := dwStat;

    > end;

    >

    > end.

    >

    >



    정확히는 모르겠지만 위에 쓰인 함수 중에 파라미터값으로 var형 변수를 갖는 것이 있는 것 같은데요. 맞는지요? 그렇다면 그 함수의 인자로 넘겨주는 값도 var형으로 써주셔야 될 것 같은데요. OpenService함수가 그렇지 않을까 모르겠네요.