Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 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
15-1173609003
oxffff
2007-03-11 13:30
2007.04.08
Встречаем Record Helper


15-1173974684
Megabyte
2007-03-15 19:04
2007.04.08
Что выбрать: VS.NET или Delphi2006.NET?


2-1173883057
Самовар глазами чайника
2007-03-14 17:37
2007.04.08
Как получить список дисков в системе


10-1130924111
Explorer
2005-11-02 12:35
2007.04.08
Обработка *.xls файлов


2-1173974049
Raptoridze
2007-03-15 18:54
2007.04.08
пропадает hook





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский