Can not open .exe with shellExecute function in C++
<p>i want to open a .exe (lets call it A)  when i execute another c++ program (lets call it B), so i have A and B in execution at the same time.</p>

<p>For this, i use this function in B code:</p>

<pre><code>HINSTANCE result;

result=ShellExecute(NULL,NULL,"d:\\Users\\bci\\Desktop\\Animation\\bin\\Release\\Animation2.exe",NULL ,NULL,SW_SHOWDEFAULT);

cout &lt;&lt; "Result is " &lt;&lt;(int)result &lt;&lt;endl;
</code></pre>

<p>Result value is 42, and A does not manage to open.
The error i get is this:</p>

<pre><code>Failed to open file "player.png": Unable to open file
Failed to load player spritesheet!
</code></pre>

<p>This corresponds to this part of A´s code:</p>

<pre><code>// load texture (spritesheet)
    sf::Texture texture;
    if (!texture.loadFromFile("player.png"))
    {
        std::cout &lt;&lt; "Failed to load player spritesheet!" &lt;&lt; std::endl;
        return 1;
    }
</code></pre>

<p>A and B were both built using code::blocks as IDE with the GCC/G++ compiler and GDB debugger from TDM-GCC (version 4.9.2, 32 bit, SJLJ).</p>

<p>I am doing this in windows 7 64 bits (enterprise and professional, both same error).</p>

<p>Also, i do not know if it is worth telling, but i am using SFML library in A, as you can see in </p>

<pre><code> sf::Texture texture;
</code></pre>

<p>I think this is related somehow to permissions for opening a file from a program you are calling, but i am not sure how to solve this.</p>

<p>Actually A and B work perfectly on their own, but B is unable to open A by this meanings.</p>

<p>I am pretty sure i have made that image as unrestricted as i can with the right click->properties->security options, but it does not seem enough.</p>

<p>Can someone help me with this?</p>