On Thursday, 13 July 2017 at 01:15:46 UTC, FoxyBrown wrote:
Everything I do results in some problem, I've tried malloc but
then converting the strings resulted in my program becoming
Heres the code:
auto schSCManager = OpenSCManager(null, null,
if (NULL == schSCManager)
print("OpenSCManager failed (%d)\n", GetLastError());
return null; // Why can't we return a null? Surely we
don't have to cast a null in to a typeof null?
DWORD dwBytesNeeded, dwCount, lpResumeHandle, resume;
auto servicesType = (SERVICE_DRIVER |
SERVICE_FILE_SYSTEM_DRIVER | SERVICE_KERNEL_DRIVER |
SERVICE_WIN32 | SERVICE_WIN32_OWN_PROCESS |
auto res = SVC.EnumServicesStatusExA(schSCManager,
&dwCount, &resume, cast(const(char)*)null);
for(int i = 0; i < dwCount; i++)
auto s = services[i].lpServiceName;
What is the signature of the function you are trying to call?
(make sure its correct :))
Allocating 5000 services may blow your stack.
you can just use `services.sizeof` instead of
You are returning that massive static array, remember that static
arrays are value types in D so that will get copied. Consider
allocating the array and returning a slice of it.
Note also that `lpServiceName` is probably a `char*` so
drefferencing will give you a char, not a string. Use
std.string.fromStringz(?) for that.