Форум: "Начинающим";
Текущий архив: 2007.04.08;
Скачать: [xml.tar.bz2];
Вниз
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 вся ветка
Форум: "Начинающим";
Текущий архив: 2007.04.08;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.041 c