Thread: exec problem

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    167

    exec problem

    If i do
    Code:
    execlp("mplayer.exe","mplayer.exe",ComboBox1->Text,NULL);
    it doesnt happen anything.
    All the path are corect and if i replace ComboBox1->Text with the path it has in it like:
    Code:
    execlp("mplayer.exe","mplayer.exe","C:\Movie.avi",NULL);
    it works just fine.
    What could the problem be?

    I use borland C++ builder!
    Thank you!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Perhaps your combo box stores things as a length, and the data (meaning there is no expicit \0).
    Copy the data to another array, and make sure there is a \0.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    167
    can execlp receive ansistrings as parameters ?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Just char* AFAIK, unless you have something OS specific going on.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    167
    well ComboBox1->Text is AnsiString... how can I convert it to char* ?

    i have this:
    Code:
    void __fastcall TMain::Button3Click(TObject *Sender)
    {
    	AnsiString S="-sub ";
    	S=S+ComboBox2->Text;
    	if(CheckBox1->Checked) S=S+" -fs ";
    	else S=S+" ";
    	S=S+ComboBox1->Text;
    	ShowMessage(S);
    //	execlp("mplayer.exe","mplayer.exe",S,NULL);
    }
    Last edited by spank; 07-22-2006 at 06:28 AM.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    *shrug*
    Read the manual pages on AnsiString and it's methods?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Dec 2005
    Posts
    167
    well... i've done something like this:
    Code:
    char *parametrii=S.c_str();
    execlp("mplayer.exe","mplayer.exe",parametrii,NULL);
    but still doesn't work

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Segmentation Fault Problem: Urgent Help
    By bodydrop in forum C Programming
    Replies: 3
    Last Post: 05-05-2006, 08:02 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM