How can application get multifiles at the same time?

HI,men
  Could I ask you some qestions about VC++ programing?
  In fact, I wanna get the work out that when draging
some files to my application, it can get these filenames
into string buffers. I know Winamp(MP3 player) can do
this. For examples, when you choose a lot of mp3 files
and press "ENTER", winamp will play them one by one
( Of course *.MP3 file should open with winamp )
Apparently, winamp get all of them. But some application
can get only one object file.
  How can I do it?
  Looking forward your suggestion.
henry3Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jhanceCommented:
See the SDK docs for DragQueryFile().

When an application receives a WM_DROPFILE message, all the files that are dropped are available via the DragQueryFile() API.  Many applications are "lazy" and don't check to see if more than one file has been dropped.

It's up to the application (i.e. the programmer) to determine how to handle or ignore multiple dropped files.
0
henry3Author Commented:
Hi,jhance
   Thanks for your advice.
   But you may not understand my purpose exactly.
   WM_DROPFILES can only get the files that you dragto the application window. In fact, I hope thatwhen you drag some files to your unruned application,
it will be active automatically, and get them.
   May be I don't express my Qestion exactly. But
How can I get the above purpose?
   After all, your answer is helpful.
0
mikeblasCommented:
When you have a shortcut on the desktop and the user drags files onto you, Windows starts your application with the file names each as separate arguments to the command line.  If the user selects 1.DAT, 2.DAT, BIG.DAT, and SMALL.DAT, then drags those files to your shortcut on the command line, you'll get each of the files on the command line as a separate argument.

Verify it for yourself with this minimal app:

-- begin file arglist.cpp --

#include <windows.h>
#include <string.h>

#pragma comment(lib, "user32.lib")

void main(int argc, char* argv[])
{
   char sz[10240];
   sz[0] = 0;

   int n;
   for (n = 0; n < argc; n++)
   {
      strcat(sz, argv[n]);
      strcat(sz, "\r\n");
   }

   MessageBox(NULL, sz, "Dang activated!", MB_OK);
}

-- end file arglist.cpp --

1) Build it
2) Create a shortcut to the EXE on your desktop
3) Start explorer
4) select some files
5) Drag 'em to the icon for the shortcut you created
6) Observe the message box.

..B ekiM

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

henry3Author Commented:
HI,Mike
   
   Thanks for your advice.
   Your anwser really can get that result.
But I don't make a ANSI C program. I wanna
a win32 VC++ program. So I don't think it is
the method I want. And anything else?
   Looking forward your suggestion.
0
jhanceCommented:
>But I don't make a ANSI C program. I
>wanna a win32 VC++ program

What are you talking about?  VC++ _IS_ an ANSI C compiler!  If you mean that you are writing a Windows GUI app and not a command line app with a main() function, the technique is still valid.

Why don't you open the SDK docs to GetCommandLine()?  Better yet, why don't you get a basic Windows programming book.  A good starting point might be Petzold's "Programming Windows" text.  

It seems to me that you don't even know enough about this subject to ask a good question, much less write some sort of MP3 application....
0
eek105Commented:
Give mblas the points and take jhance's advice
0
mikeblasCommented:
The above app _is_ a Win32 app.  I guess you mean that you want something that works as a Windows application.  That's fine, we can do that, too.

1) Start VC++.
2) Ask for an MFC AppWizard (exe) application
3) Call it Foo.
4) Ask for a Dialog-based application
5) Accept all the rest of the defaults.
6) Add these lines to the CFooDlg::OnInitDialog() function. You should add them right under the comment that says "TODO: Add extra initiailzation here"

   CListBox* pBox = (CListBox*) GetDlgItem(IDC_LIST1);

   int n;
   for (n = 0; n < __argc; n++)
   {
      pBox->AddString(__argv[n]);
   }

7) Edit the IDD_FOO_DIALOG resource in your app.
8) Delete the "TODO" text in the middle of the dialog.
9) Drop a nice big list box control in the middle of the box.
10) Build the app.

Then, you can follow the same instructions I gave before to place this guy on your desktop. It'll work just the same, except you'll see that you can still just pick the filenames off the command line.

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
henry3Author Commented:
To Mikeblas:
   Thanks for your advice.
   I got what I want.
   I have some C and C++(DOS) program EXP,
but I turn to Windows Programming recently.
So I'll face to many qestions with VC++.
   In fact, I mean that I don't make a
command line app with a main() function
as jhance said. So, the "_argc" and "_argv[]
is just what I need.
 
To jhance:
   I think that practice is the best way to
study program, instead of handbook-swallowing.
   So,please take all of your sarcasm back.
If you think the qestion is too simple, you
should ignore it.
   Although you are the expert of the week,
I think I'll be better than you someday.  
   And maybe you have super skill, but as a guide
Mike is much more qualified than you.
0
henry3Author Commented:
I got it!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.