Results 1 to 3 of 3

Thread: Simple code?

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    Simple code?

    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:
    VB Code:
    1. 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
    2. Private Const SW_SHOWNORMAL = 1
    3.  
    4. Sub Main()
    5. ShellExecute hWnd, "open", App.Path & "\index.html", vbNullString, vbNullString, SW_SHOWNORMAL
    6. End
    7. End Sub

    Thanks a lot
    Joey
    <removed by admin>

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Code:
    #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;
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Thanks for the reply. That worked perfect! Thank you so much!
    <removed by admin>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width