If statement question part 2

Posted on 2006-03-26
Last Modified: 2010-04-05
Hi All,

I have the following 2 problems in code, so can someone please tell me what exactly I am doing wrong in them:

   SCM := OpenSCManager(Nil, Nil, SC_MANAGER_ALL_ACCESS);

   if SCM <> Nil then

In the above block of code I always get an error:
[Error] Unit1.pas(175): Operator not applicable to this operand type

So can someone please tell me what exactly I am doing wrong here?

if ChangeServiceConfig(SCH, SERVICE_NO_CHANGE, SERVICE_AUTO_START,SERVICE_NO_CHANGE,Nil,Nil,Nil,Nil,Nil,Nil,PChar(ServiceName) ) <> 0 then

I always get Error: [Error] Unit1.pas(180): Incompatible types

So can someone please tell me what exactly I am doing wrong here?
Question by:GiantMatrix
    1 Comment
    LVL 26

    Accepted Solution


    1.) SC_HANDLE is not a pointer type, its defined as :

    SC_HANDLE = THandle;

    so, check (SC_HANDLE <> 0);

    2.) The ChangeServiceConfig returns a BOOL (longbool) type, so checking against <> 0 is incorrect. It should be:

     if ChangeServiceConfig(SCH, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, nil, nil, nil, nil, nil, nil, PChar(ServiceName)) then



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now