PDA

Click to See Complete Forum and Search --> : Simple code?


MidgetsBro
Apr 29th, 2002, 04:04 AM
I want to make a simple C++ program that will be put on a CD that when ran, it will open an html file on the CD, and then just quit the program. I don't want console or anything, just a quick load, and unload that I can put in my autorun.inf file. I tried adding index.html to the autorun, but it needs a valid Win32 executable to run. Can anyone help me with the code? I have this in my VB Sub Main() but the user might not have the vb runtimes installed:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1

Sub Main()
ShellExecute hWnd, "open", App.Path & "\index.html", vbNullString, vbNullString, SW_SHOWNORMAL
End
End Sub


Thanks a lot
Joey

CornedBee
Apr 29th, 2002, 06:07 AM
#include <windows.h> // the declares are in headers in C++

// the equivalent to sub main
int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// the ShellExecute call
ShellExecute(NULL, NULL, "index.html", NULL, NULL, SW_SHOWNORMAL);
return 0;
}

MidgetsBro
Apr 29th, 2002, 04:36 PM
Thanks for the reply. That worked perfect! Thank you so much!