🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Copy Files

#5558
From: Ed Mulroy
Date: Mon, 08 Aug 2005 00:48
69 lines
2625 bytes
Check the source code you posted.

It is hard to decipher with all indenting removed but it looks as if the 
'try' statement is terminated with

  else if(hGbl != NULL)

.  Ed

> Alexander Adam wrote in message
> news:42f6a8ab@newsgroups.borland.com...
>
> I am trying to copy a list of files into the clipboard. In the following 
> is my code but it doesn't work (acess error with memory or something that 
> the CodeGuard tells me).. any clue or maybe some more simple code to do 
> what I want?
>
> AnsiString ShellConcatFiles(TStrings* sourceFiles) {
> AnsiString tmpStr = "";
> for(int i=0; i<sourceFiles->Count; i++) {
> tmpStr += sourceFiles->Strings[i];
> tmpStr += '\0';
> }
> return tmpStr;
> }
>
> bool CopyFilesToClipboard(TStrings* sourceFiles)
> {
>
> AnsiString tmpList = ShellConcatFiles(sourceFiles);
> char* FileList = new char[tmpList.Length() + 1];
> try {
> strcpy(FileList, tmpList.c_str());
>
> int len;
> BYTE* pData;
> HGLOBAL hGbl;
> DROPFILES hf;
>
> if (!OpenClipboard(0))
> return false;
> EmptyClipboard();
>
> hf.fNC = false;
> hf.fWide = false;
> hf.pFiles = sizeof(hf);
> hf.pt.x = hf.pt.y = 0;
>
> len = tmpList.Length() + 2;
> hGbl = GlobalAlloc(GHND, sizeof(hf)+len);
> pData = (BYTE*)GlobalLock(hGbl);
> if (pData != NULL) {
> memcpy(pData, &hf, sizeof(hf));
> memcpy(pData+sizeof(hf), FileList, len);
> GlobalUnlock(hGbl);
> if (!SetClipboardData(CF_HDROP,hGbl)) {
> GlobalFree(hGbl);
> hGbl = NULL;
> }
> } else if(hGbl != NULL) {
> GlobalFree(hGbl);
> hGbl = NULL;
> }
> CloseClipboard();
> return hGbl != NULL;
> } __finally {
> delete FileList;
> }
> }
Technical Details
Message-ID: <42f6abc3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42f6a8ab@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,a3b46c11acc1d35f
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ed Mulroy" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <42f6a8ab@newsgroups.borland.com>
Subject: Re: Copy Files
Date: Sun, 7 Aug 2005 20:48:01 -0400
Lines: 71
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 69.134.170.196
Message-ID: <42f6abc3$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1123462083 69.134.170.196 (7 Aug 2005 17:48:03 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail