Вниз
Скачать: CL | DM;

Function WinSvc.GetServiceDisplayName   Найти похожие ветки 

← →
koha ©   (2007-03-21 02:07) [0]

Никак не могу понять как же DisplayName в строку загнать.
В справке написано

"Pointer to a null-terminated string that receives the service"s display name. If the function fails, this buffer will contain an empty string."

-  не допонимаю о чем сдесь говорится?

GetServiceDisplayName(
 SC_HANDLE hSCManager,
 LPCTSTR lpServiceName,
LPTSTR lpDisplayName,
 LPDWORD lpcchBuffer

);


Никак не могу тип lpDisplayName подставить компилятор ругается, что тут сделать надо, что бы DisplayName в String получить


← →
Германн ©   (2007-03-21 02:14) [1]


> LPTSTR

Это в Дельфи соответствует типу PChar.

> Никак не могу тип lpDisplayName подставить компилятор ругается,
>  что тут сделать надо, что бы DisplayName в String получить

А вот вместо этого "никак не могу" стоило бы привести твой код на который кто-то ругается.


← →
koha ©   (2007-03-21 02:25) [2]

Я по разному пробывал, дело в том, что не знаю как надо.

Var DispName : array[0..1023] of Char;
.......................
WinSvc.GetServiceDisplayName(hSrv,PChar(DrvName),DispName,SizeOf(DispName));

- так точно не получается
[Pascal Error] Unit1.pas(78): E2033 Types of actual and formal var parameters must be identical
[Pascal Fatal Error] Stop_Service.dpr(5): F2063 Could not compile used unit "Unit1.pas"


← →
Германн ©   (2007-03-21 02:25) [3]

Кстати в справке для Д6 немного другое описание:
lpDisplayName

Points to a buffer into which the function stores the service"s display name as a null-terminated string. If the function fails, this buffer will contain an empty string.


← →
koha ©   (2007-03-21 02:31) [4]

Пробывал и так:

var DispName : String;
//....................
SetLength(DispName,1024);
WinSvc.GetServiceDisplayName(hSrv,PChar(DrvName),PChar(DispName)^,SizeOf(DispNam e));


- не выходит.


← →
Германн ©   (2007-03-21 02:35) [5]


> koha ©   (21.03.07 02:25) [2]
>
> Я по разному пробывал, дело в том, что не знаю как надо.
>
>
> Var DispName : array[0..1023] of Char;
> .......................
> WinSvc.GetServiceDisplayName(hSrv,PChar(DrvName),DispName,
> SizeOf(DispName));
>

Обрати внимание на последний параметр функции.
lpcchBuffer

Points to a DWORD that contains the size, in characters, of the buffer pointed to by lpDisplayName. When the function returns, this DWORD contains the size, in characters, of the service"s display name, excluding the NULL terminator.
If the buffer pointed to by lpDisplayName is too small to contain the display name, the function stores no data into it. When the function returns, the DWORD pointed to by lpcchBuffer contains the size in characters of the service"s display name, excluding the NULL terminator.


← →
koha ©   (2007-03-21 03:35) [6]

Кажись тепереча получилось!

Var SrvStatus: TServiceStatus;
Const LongueurMaxNomSvr = 255;
var NomService : Array[0..LongueurMaxNomSvr+1] of Char;
   TailleBuffer: DWord;

begin
hSCMan:=WinSvc.OpenSCManager(Nil, Nil, SC_MANAGER_CONNECT);
If hSCMan = 0 then begin
  mmInf.Lines.Add("OpenSCManager = false");
  Exit;
end;
mmInf.Lines.Add("OpenSCManager = true");

hSrv:= WinSvc.OpenService(hSCMan,PChar(DrvName), SERVICE_ALL_ACCESS);
If hSrv = 0 then begin
  mmInf.Lines.Add("hSrv = filse");
  exit;
end;

WinSvc.ControlService(hSrv,SERVICE_QUERY_STATUS,SrvStatus);

FillChar(NomService,SizeOf(NomService),#0);
TailleBuffer:=LongueurMaxNomSvr+1;

GetServiceDisplayName(hSrv,PChar(DrvName),NomService,TailleBuffer);

mmInf.Lines.Add(StrPas(NomService)+" "+GetSrvStatus(SrvStatus));

WinSvc.CloseServiceHandle(hSrv);
WinSvc.CloseServiceHandle(hSCMan);



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.027 c
15-1173679308
vasIZmax
2007-03-12 09:01
2007.04.08
Первые проблемы...


1-1171449391
Kyn66
2007-02-14 13:36
2007.04.08
Высота DBGridEh в зависимости от количества строк


2-1174130498
Boker
2007-03-17 14:21
2007.04.08
TTreeView Развернуть и свернуть


2-1173990985
dzhagr
2007-03-15 23:36
2007.04.08
SQL create table


2-1174151568
vegarulez
2007-03-17 20:12
2007.04.08
Как в TEdit разрешить записаь только цифр?




   Наверх