🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15706

Re: Run program against file

#15706
From: cpp3003
Date: Mon, 16 Jun 2003 19:30
122 lines
4587 bytes
Yes, I have compiled other programs which do work. The coding below is what
I am attempting to run. Have I misapplied this code in any way ? It compiles
without error. GetDesktopWindow does not appear to be working, for some
reason. I have no clue what to do for this.

 #include <windows.h>

  WORD WINAPI SelectFile(
    HWND parent,
    const char *initial_directory,
    const char *
    title,
    char *full_name)
    {
    OPENFILENAME ofn;
    char         file_name[MAX_PATH + 1];

    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);

    ofn.hwndOwner = parent;
    ofn.lpstrTitle = title;
    ofn.nMaxFileTitle = lstrlen(title);

    *full_name = '\0';
    ofn.lpstrFile = full_name;
    ofn.nMaxFile = MAX_PATH + 1;

    ofn.lpstrFileTitle = file_name;
    ofn.nMaxFileTitle = MAX_PATH + 1;

    ofn.lpstrInitialDir = initial_directory;

    ofn.lpstrFilter = "Executable Files\0*.EXE\0\0";

    ofn.Flags = OFN_FILEMUSTEXIST    | OFN_LONGNAMES    |
                OFN_NOREADONLYRETURN | OFN_HIDEREADONLY |
                OFN_PATHMUSTEXIST    | OFN_EXPLORER;

    SetLastError(0);

    if (!GetOpenFileName(&ofn))
      {
      DWORD errnum = CommDlgExtendedError();
      char  err_buf[512];

      wsprintf(err_buf, "File Selection Error %08X/%u", errnum);
      MessageBox(parent, err_buf, "", MB_OK);
      *full_name = '\0';
      *file_name = '\0';
      ofn.nFileOffset = (WORD) -1;
      }
    else
      {
      // create a pointer to the 1st char following the directory
      lstrcpy(file_name, full_name + ofn.nFileOffset);
      }

    return ofn.nFileOffset;
    }


  int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    char file_name[MAX_PATH + 1];

    int result = SelectFile(GetDesktopWindow(),
                 "C:\\",
                 "sumfile.exe",
                 file_name);

    if (result != -1)
      {
      MessageBox(HWND_DESKTOP, file_name,
        "Selected File", MB_OK);
      }

    return 0;
    }

- Thanks -







"Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> wrote in message
news:3eee1411$1@newsgroups.borland.com...
> > ...I tried to e-mail you directly ...
>
> Had you looked at the address you'd have known how to fix the problem of
it
> not being deliverable.  However, while I try to help on in public messages
> on here, I do not do private, free consulting.  You are not supposed to
> email me directly.  Look at the newsgroup guidelines in Borland's web
page:
>   http://info.borland.com/newsgroups/guide.html
>
> Something else is wrong.  You are using the command line tools from C++
> Builder 5.  I tried it with the command line tools from C++ Builder 4 and
> from C++ Builder 6.  It is unlikely to now work with C++ Builder 5.
>
> You have not described any problems, errors or warnings in building the
file
> so there is no indication that your header file is at fault.
>
> Have you been able to build other programs on that machine with that
> compiler?
>
> .  Ed
>
> > cpp3003 wrote in message
> > news:3eee0645$1@newsgroups.borland.com...
> >
> > Ok, I am using Borland 5.5 free compiler. I must be missing
> > something in my <windows.h> file. Wish I could have made
> > it work. Also, I tried to e-mail you directly, but, your e-mail
> > address returned an undeliverable.
>
>
Technical Details
Message-ID: <3eee1a55$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3ee8f082$1@newsgroups.borland.com> <3ee8fc5c@newsgroups.borland.com> <3ee9dde6$1@newsgroups.borland.com> <3eea79f9$1@newsgroups.borland.com> <3eedd330$1@newsgroups.borland.com> <3eedf7f3@newsgroups.borland.com> <3eee0645$1@newsgroups.borland.com> <3eee1411$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,7bb2502e61022b33
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-06-16 12:36:10 PST
Reply-To: "cpp3003" <cpp3003@yahoo.com>
From: "cpp3003" <cpp3003@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3ee8f082$1@newsgroups.borland.com> <3ee8fc5c@newsgroups.borland.com> <3ee9dde6$1@newsgroups.borland.com> <3eea79f9$1@newsgroups.borland.com> <3eedd330$1@newsgroups.borland.com> <3eedf7f3@newsgroups.borland.com> <3eee0645$1@newsgroups.borland.com> <3eee1411$1@newsgroups.borland.com>
Subject: Re: Run program against file
Date: Mon, 16 Jun 2003 15:30:19 -0400
Lines: 124
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 157.232.192.53
Message-ID: <3eee1a55$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1055791701 157.232.192.53 (16 Jun 2003 12:28:21 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail