Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8388709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:31:52+00:00 2026-06-09T18:31:52+00:00

The following piece of code doesn’t make an application to run. Can some one

  • 0

The following piece of code doesn’t make an application to run. Can some one please point out what could be the problem?

procedure TTestForm1.DR_DBA_StartAppButtonClick(Sender: TObject);
var
  StartInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
  filename : String;
  sa : TSecurityAttributes;
  sd : TSecurityDescriptor;

begin

  InitializeSecurityDescriptor( @sd, SECURITY_DESCRIPTOR_REVISION );
  SetSecurityDescriptorDacl( @sd, true, nil, false);

  sa.nLength := sizeof( sa );
  sa.lpSecurityDescriptor := @sd;
  sa.bInheritHandle := true;

  // start app process
  ZeroMemory(@StartInfo, SizeOf(TStartupInfo));
  StartInfo.cb := SizeOf(TStartupInfo);

  if not
    CreateProcess (nil, PChar(SF_AppPathBox.Text), @sa, @sa, False,
    PROCESS_VM_WRITE or PROCESS_VM_OPERATION, nil, nil, StartInfo, ProcInfo) then
  begin

    showmessage ('Cannot Start App');
    exit;

  end;

end;

This code ran perfectly well for an older alpha build with different UI but now after the implementation of a new UI design, it doesn’t.

The GetLastError function returns an error code of 2, the system cannot find the file specified.

The path defined is correct as it is extracted from the installdir registry entry made by the application. I have also tried manually including it but to no avail.

'X:\App\PB 0.93\PB.exe'

I am using DxScene v4.42 for UI design and the path is extracted from TVxTextBox. Putting in constant path works but not from the text box although both are system strings. I have compared both strings with each other through CompareStr which resulted in a complete match.

I am working on Windows 7 64/32bit and Windows XP SP2/3 32bit.

Findings

DxScene components inherently use unicode strings which are incompatible with createprocess procedure.

So I stored the required path strings first in normal strings and then passed them as parameter to create process which worked.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:31:53+00:00Added an answer on June 9, 2026 at 6:31 pm

    It appears that you have a mismatch between Unicode and Ansi text. You are using UI controls that use Unicode, but are compiling in an Ansi Delphi. So you are passing an array of 16 bit characters to a function that expects 8 bit encoded text. Which explains the error code that is reported.

    It’s possible that the code worked for the original developers because they used a modern Unicode Delphi. If that is the case then your best course of action is to compile the code with the version of Delphi in which it was originally compiled.

    If you must use an Ansi Delphi then you can fix your code by passing

    PChar(string(SF_AppPathBox.Text))
    

    to CreateProcess. That will have the effect of converting from Unicode to Ansi.

    You could alternatively call the Unicode version of CreateProcess like this:

    CreateProcessW(..., PWideChar(WideString(SF_AppPathBox.Text)), ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code (doesn't matter if it's a good method
I am trying the following piece of code in java, but it doesn't seem
I recently came across the following piece of code. It doesn't look valid because
the following piece of code works fine when i use it among some code
I have the following piece of code that takes in some words, stores them
I have the following piece of code which doesn't compile when I try to
Consider the following piece of code: As you can see we are on line
I would think the following piece of code should work, but it doesn't (Edited:
i have the following piece of code, that for some reason that i'm unaware
I got the following piece of code, but it doesn't seem to get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.