Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to copy/paste/cut files from within a Delphi app?

1,039 views
Skip to first unread message

Ivan Pekarik

unread,
Feb 1, 1999, 3:00:00 AM2/1/99
to
Hey everyone... I was wondering... How can you copy/paste/cut files on
any drive from within a Delphi app? Do you maybe know a way to search
the hard drive for a file (something like the Windows Find program).

Thanks!

Peko
(branko....@sb.tel.hr


Steffen Haugk

unread,
Feb 1, 1999, 3:00:00 AM2/1/99
to
To get the windows FIND (files and folders) dialog:

SendMessage(FindWindow('Progman', 'Program Manager'), WM_HOTKEY,
5,4587528);

For the FIND Computer:

SendMessage(FindWindow('Progman', 'Program Manager'), WM_HOTKEY,
6,4587530);


HTH

Best regards, Steffen

Peter Below (TeamB)

unread,
Feb 2, 1999, 3:00:00 AM2/2/99
to
>
> Hey everyone... I was wondering... How can you copy/paste/cut files on
> any drive from within a Delphi app? Do you maybe know a way to search
> the hard drive for a file (something like the Windows Find program).
>
Peko,

there is a full range of file management functions both in Delphis
run-time lib and the Windows API. Look at CopyFile, MoveFile (both
Windows, win32.hlp), DeleteFile (Sysutils or Windows), ShFileOperation
(ShellAPI, win32.hlp). To search for files you use FindFirst, FindNext,
FindClose (all Sysutils). One of the example programs that comes with
Delphi (filmanex) is a simple file manager that shows how to handle this
kind of file operations.


Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitely requested!


Jim O'Brien

unread,
Feb 3, 1999, 3:00:00 AM2/3/99
to
In article <36B61253...@sb.tel.hr>, Ivan Pekarik wrote:
> Hey everyone... I was wondering... How can you copy/paste/cut files on
> any drive from within a Delphi app?
>
<http://www.unitoops.com/uoole/examples/clipboardtest.htm> shows how to
cut/copy/paste files and shortcuts to/from Explorer (and, therefore, the
desktop).

--
Wed, 03 Feb 1999 10:39 EST
Jim O'Brien, UnitOOPS Software unit...@remove-this-prefix.unitoops.com
Check out our OLE Drag and Drop Components at <http://www.unitoops.com/>
Browse examples online at <http://www.unitoops.com/uoole/examples/>


Jim O'Brien

unread,
Feb 4, 1999, 3:00:00 AM2/4/99
to
In article <36B8D86B...@cent.co.yu>, Dejan Maksimovic wrote:

> > Hey everyone... I was wondering... How can you copy/paste/cut files on
> >
>

> Does anyone know of a better way to do this? Using components to do this
> is not very convinient.
>
If you read the example, you'll see it doesn't even require the components. It shows, using some
well-commented code, how to go about doing file and shortcut clipboard operations, and supplies
(through the uoUtil unit that accompanies the trial and full versions of the components) a routine
to make it easier to construct the two data structures expected by the clipboard. You can use
this routine freely even if you don't license the components, but you don't even have to use it if
you don't want to. In other words, *you don't have to use components to do this*.

>Unitoops are not very fast for such tasks!!!
>
I have *NO* idea what you mean by this. Can you please explain to everyone? It looks like you're
suggesting our product is deficient in some way, but you offer no description of what you think is
wrong. In fairness to all, but in particular to us, you should elaborate on this. Or is your
comment something akin to "hammers are not very fast for cutting planks?"

--
Thu, 04 Feb 1999 07:45 EST

Steve Schafer (TeamB)

unread,
Feb 4, 1999, 3:00:00 AM2/4/99
to
On Thu, 04 Feb 1999 08:12:21 EST, Jim O'Brien
<unit...@remove-this-prefix.unitoops.com> wrote:

>"hammers are not very fast for cutting planks?"

Sure they are...if they're big enough.

-Steve


Dejan Maksimovic

unread,
Feb 4, 1999, 3:00:00 AM2/4/99
to unit...@remove-this-prefix.unitoops.com
Well, it is very well known that using classes to wrap API calls is
slower than the real API implementation ( but is very easier ). Besides,
it takes much more memory.


Dejan.


Anders Melander

unread,
Feb 4, 1999, 3:00:00 AM2/4/99
to
Dejan Maksimovic <ma...@cent.co.yu> wrote:

Ehem... Are you serious?
Unless you are planning to cut/copy/paste thousand of files
simultaneously per second, I can't really see the overhead we are
talking about having *any* relevance at all.

The overhead for wrapping an API call will usually be about 10-20
instructions, which will probably account for less than .5% of the
instructions executed by the API call itself. The memory overhead can
of course vary greatly, but it isn't more than 50-100 bytes for simple
classes.

Now, why don't you tell us what your *real* problem is?


Thank you for flying Air Melander.

+--------------------from usenet----------------------+
| Anders Bo Melander | Phone: (+45) 38 87 91 26 |
| Finsensvej 79, 2. tv. | mailto:and...@melander.dk |
| DK-2000 Frederiksberg | http://www.melander.dk |
| Denmark | flameto:bi...@microsoft.com|
+------------------------+----------------------------+

Dejan Maksimovic

unread,
Feb 5, 1999, 3:00:00 AM2/5/99
to and...@melander.dk
This is the real problem.
To use components for complex tasks ( e.g. 200 lines of API code
compared to 5 lines of class code ) is OK. But, drag/drop has less than
10 lines needed ( the API part ). You may think of it that way ( only 5%
overhead in speed/memory), but 5% here, 5% there makes the diferrence
between a app that does work in 10 hours vs. an app that does it in 9
hours. This isn't small time.
You'll have to think about long time operations.
Get the picture now.
Besides, whenever there was a question about how to copy/cut/paste
files the only answers were "use UnitOops", and this is the winapi
newsgroup. Give others a chance.


Dejan.


Jim O'Brien

unread,
Feb 5, 1999, 3:00:00 AM2/5/99
to
In article <36BAB4C9...@cent.co.yu>, Dejan Maksimovic wrote:
> But, drag/drop has less than
> 10 lines needed ( the API part )
>
Bzzzzzt...wrong. Sure, you use RegisterDragDrop() and DoDragDrop() to initiate
dragging and drop acceptance respectively, but you need to pass these API's COM
interface *implementations* (i.e., code you have to write yourself!) that,
believe me, are more than a few lines!

In order to implement any of the standard interfaces (whether for drag and
drop, shell context menus, etc, etc) in the WinAPI, you have to write your own
code. This is the essence of the *component* object model (COM). Wrapping the
implementation of those COM interface (that you'd have to write regardless of
the language you were using) in a VCL component for convenience is just another
layer.

The performance impact is not even an issue.

> Besides, whenever there was a question about how to copy/cut/paste
> files the only answers were "use UnitOops", and this is the winapi
> newsgroup
>

Not so. I pointed you to an example, fully commented, that doesn't require ANY
components.

--
Fri, 05 Feb 1999 07:24 EST

Jim O'Brien

unread,
Feb 5, 1999, 3:00:00 AM2/5/99
to
In article <3753c1c9....@90.0.0.40>, Steve Schafer (TeamB) wrote:
> Sure they are...if they're big enough.
>
It's people like you wot cause unrest. <g>

--
Fri, 05 Feb 1999 07:49 EST

Jim O'Brien

unread,
Feb 5, 1999, 3:00:00 AM2/5/99
to
In article <36BAB4C9...@cent.co.yu>, Dejan Maksimovic wrote:
> You'll have to think about long time operations.
>
Drag and drop is inherently a "short time" operation. Look at it this way - if
it doesn't work fast enough, the user will tell you it doesn't work at all!

But either way, this is rarely an issue even outside of drag and drop.

--
Fri, 05 Feb 1999 07:50 EST

Tony Tanzillo

unread,
Feb 6, 1999, 3:00:00 AM2/6/99
to
Jim O'Brien wrote:

>
> In article <36B61253...@sb.tel.hr>, Ivan Pekarik wrote:
> > Hey everyone... I was wondering... How can you copy/paste/cut files on
> > any drive from within a Delphi app?
> >
> <http://www.unitoops.com/uoole/examples/clipboardtest.htm> shows how to
> cut/copy/paste files and shortcuts to/from Explorer (and, therefore, the
> desktop).

Don't you think it is just a bit sleazy of you to
suggest someone look to an example that REQUIRES
YOUR PRODUCT, to do something like this?

Do you know what the meaning of the term 'commercial
exploitation' is?

How about clearly marking your sales pitch in-disguise
to make it clear that it is not a pointer to generic
example code, but in fact, nothing but a sales pitch.

Jim O'Brien

unread,
Feb 6, 1999, 3:00:00 AM2/6/99
to
In article <36BC6BDD...@worldnet.att.net>, Tony Tanzillo wrote:
> Don't you think it is just a bit sleazy of you to
> suggest someone look to an example that REQUIRES
> YOUR PRODUCT, to do something like this?
>
> Do you know what the meaning of the term 'commercial
> exploitation' is?
>
> How about clearly marking your sales pitch in-disguise
> to make it clear that it is not a pointer to generic
> example code, but in fact, nothing but a sales pitch.
>
Here's a response written after several deep breaths, but I could probably have
used a few more...

The example DOESN'T REQUIRE OUR PRODUCT. It contains COMPLETELY GENERIC CODE
for clipboard operations involving files, aside from one or two helper
functions that you can either use FOR FREE from our support library, or write
your own. From the web site description of this example:

"Demonstrates manipulating "fancy" clipboard formats using the helper functions
in the uoUtil unit. While this is not directly related to drag-and-drop, the
universal data transfer mechanism underlies both, so there are many concepts in
common. We show the specific example of putting file names in the clipboard so
that the shell (Explorer) will offer the choice to paste them, or paste them as
shortcuts. The converse - getting file names from the clipboard, put there by a
copy operation in the shell - is also demonstrated. "

In a posting 2 days before your attack, I had even explained at length that
this clipboard stuff had no requirement for our components. DIDN'T YOU READ
THAT ONE?

Finally, if you look at any prior responses where I mention a solution that
requires or is aided by our product, I ALWAYS SAY SO EXPLICITLY. I even point
out certain workarounds where NO THIRD-PARTY COMPONENTS ARE REQUIRED. And by
the way, I respond to questions in LOTS of areas COMPLETELY UNRELATED TO OUR
PRODUCTS. Ask anyone who frequents these groups.

There. I feel a bit better now. You probably will, too, after you tone it
down a bit. I'd also appreciate a retraction of your off-the-mark loose-cannon
post that could undeservedly damage my reputation, not to mention my business,
in the eyes of the casual reader.

--
Sat, 06 Feb 1999 14:06 EST

Mike Orriss

unread,
Feb 7, 1999, 3:00:00 AM2/7/99
to
In article <36BC6BDD...@worldnet.att.net>, Tony Tanzillo wrote:
> Don't you think it is just a bit sleazy of you to
> suggest someone look to an example that REQUIRES
> YOUR PRODUCT, to do something like this?
>

LOL! You don't change.

Perhaps if you read the rest of the thread you might have noticed that
there is no requirement to use Jim's component - he was offering a free
source code solution.

Mike Orriss (m...@3kcc.co.uk)
http://www.3kcc.co.uk/notetree.htm


Ivan Pekarik

unread,
Feb 7, 1999, 3:00:00 AM2/7/99
to Ivan Pekarik

Ivan Pekarik wrote:

> Hey everyone... I was wondering... How can you copy/paste/cut files on

> any drive from within a Delphi app? Do you maybe know a way to search
> the hard drive for a file (something like the Windows Find program).
>

> Thanks!
>
> Peko
> (branko....@sb.tel.hr

Look guys, I appreciate all the cool ideas and stuff, but you dont have to
make a war zone here. You all have different methods, and I don't care
about those 5% here or 5% there, I don't care if it's faster or slower
than 3.0684872 seconds and I dont care if it has three or three hundred
lines of code, as long as it works. We're all on the same side here! All I
wanted to do is to learn something about the file managment in Delphi (I
wanted to make a simple File Manager). I'm not very good at making
programs in Delphi, so I thought I could use your help. I'm sorry if I got
you fighting. SO PLEASE STAY COOL!!!

Thank you!
Peko


Jim O'Brien

unread,
Feb 7, 1999, 3:00:00 AM2/7/99
to
In article <36BDA09C...@yahoo.com>, Dejan Maksimovic wrote:
> I don't know of a way to cut/copy or paste files like explorer
>
That's just the point. I showed you how to do it by directing you to
<http://www.unitoops.com/uoole/examples/clipboardtest.htm>

--
Sun, 07 Feb 1999 16:24 EST

0 new messages