Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Having some trouble with dbExecuteFile

Author
Message
Howy
13
Years of Service
User Offline
Joined: 12th Feb 2007
Location:
Posted: 13th Mar 2012 22:52 Edited at: 14th Mar 2012 02:00
Ok, so I'm having a bit of trouble with this command. I'm trying to get VLC to open a video file through this. When I type it all out, the command is underlined with the error "no instance of overloaded function 'dbExecuteFile' matches the argument list". This was the command I tried to type out:


I previously set the executable's directory and the video to load to their strings. I pretty much converted the code from my DbPro project's code, which works perfectly:



I'm not really getting what I'm doing wrong in C++ with this. Can someone help me out here?

EDIT: I've just tried typing the directories into the command instead of using an assigned string name, and I don't get an error. Instead, it just ignores the command completely and goes to the next part of the program. Anyone know what's wrong with this?
xix psycho xix
12
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 14th Mar 2012 14:21
what are the types of the variables that you are passing to the function?
Howy
13
Years of Service
User Offline
Joined: 12th Feb 2007
Location:
Posted: 14th Mar 2012 18:51
I'm passing all strings into the function, along with 1 for the wait flag. I guess it would help if I post my entire code huh



It's supposed to first print all the files in the directory (The perform checklist for files example from dbpro), pick a random file, then print what file it picked and open it in vlc. The execute file function commented out is the one that gives the error. The one that isn't commented won't give an error, but it gets completely skipped over without any sort of runtime error, going straight to the print "VLC PLAYER" function. Like I said, the code works just fine in dbPro, so I'm guessing I screwed up somehow with the execute file.
Hassan
11
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 14th Mar 2012 22:03
does dbExecuteFile ask for a string or a const char*?try


also for your code without variables, it looks like you missed something:
while the other one is
( /Program Files (x86) )

Howy
13
Years of Service
User Offline
Joined: 12th Feb 2007
Location:
Posted: 15th Mar 2012 20:03 Edited at: 15th Mar 2012 22:48
Just tried adding .c_str, sadly that didn't work. Also just checked the definitions the ide gives for the function, and it's asking for a char*:



Which I find odd since in dbPro it asks for strings. And the directory thing for vlc wasn't a mistake. When I posted the code I had copied the VLC directory to the root of my C drive to see if that would fix anything. Didn't happen lol. So at the moment either of those directories for the string should work fine for me.


EDIT: Made a little progress. I converted the strings to chars by declaring a char * and assigning it to (char*)mystring.c_str(), which got rid of the error, however it still ignores the function, skipping to dbPrint("VLC PLAYER");



Oddly, if I go to line 34 and edit svlcexe.c_str(); to vlc.c_str(); like the one above it, then it will open the vlc folder. I still have no idea what I'm doing wrong here.
WLGfx
12
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th Mar 2012 05:03
I've not tried executing the test code above yet that you've supplied but from what I can see the dbExecuteFile() function takes many arguments which would usually mean that all arguments would have to be of the same type.

Instead of: dbExecuteFile("vlc", "C:/Users/Dolan/Videos/MyVideo.mp4", "C:/VideoLAN/VLC", 1);

Try using: dbExecuteFile("vlc", "C:/Users/Dolan/Videos/MyVideo.mp4", "C:/VideoLAN/VLC", "1");

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Howy
13
Years of Service
User Offline
Joined: 12th Feb 2007
Location:
Posted: 17th Mar 2012 18:02
That doesn't work. It's asking for an int for the wait flag, not a string or char*.

Actually, does C++ already have a function for executing a file with a command? Maybe that would work?
WLGfx
12
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th Mar 2012 22:09 Edited at: 17th Mar 2012 22:15
Yes, something like:

ShellExecute(GetDesktopWindow(), "open", "c:\myTestFolder\myfile.exe", NULL, NULL, SW_SHOWNORMAL);

More information on MSDN...

However if you need a return value then you'll need to use ShellExecuteEx(), information about it is HERE...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Howy
13
Years of Service
User Offline
Joined: 12th Feb 2007
Location:
Posted: 19th Mar 2012 19:36
Okay, i've ALMOST got it working. I've gotten both ShellExecute() and ShellExecuteEx() working. Instead of launching vlc and the the file with a command parameter, I just opened the file , but I seem to have a little problem.

First, when I typed you're code for ShellExecute, I had gotten an LPCWSTR error, but luckily I found a function online to fix that . With the ShellExecuteEx() function, it will run the file, but when it finishes and VLC closes, the program freezes for anywhere between 5 and 20 seconds (freeze as in I can't even close it, I have to click the stop debug button) before continuing. Plus, it won't run another file when the loop comes back around to the function. Like before, it completely skips that part of the code and prints "SHELLEXECUTE". It'll do this for both ShellExecute and ShellExecuteEX. Although, if I change the video string to directly point to a video file instead of letting it choose a random file, it will load just fine each time.



Here's my current code. The video string that points to a file and ShellExecute are commented out.
WLGfx
12
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Mar 2012 03:40 Edited at: 20th Mar 2012 03:47
I'll have a proper look at this in the morning after the carpet people have been and gone. My only guess at the moment is the system is still thinking the process is running.

In the meantime, you could try the old method function call - system(const char* cmd) - Reference HERE... This might just be a lot easier to use even than ShellExecute(). It's used to run command line like calls and it returns the exit code from the process.

Apart from that, you could always try a different option and look into the ffmpeg library which allows you to playback video files without calling external programs.

EDIT: I'm also just reading up on fork() and exec() functions to which seem to be a slightly safer option to using system().

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2020-09-18 11:14:39
Your offset time is: 2020-09-18 11:14:39