|
|
Can you tell me the code to delete a file in Vc++ 6.0?
thank you very much.
|
|
|
|
|
|
You can use SHFileOperation to delete a file
or
You can use the API _unlink()
Ankush
|
|
|
|
|
I have a string, such as "Hello World!"
I want copy it to clipboard, so that, after that, when I right click in a word process application ( such as: NotePad, WordPad, Word...), there is a "paste" menu command show for me to paste that string "Hello World!"
My code is wrong (GlobalUnlock) but I dont know how to fix it (I am following code in MSDN sample)
thanks!
BOOL CopyToClipBoard(LPSTR lpszString)<br />
{<br />
LPTSTR lptstrCopy; <br />
HGLOBAL hglbCopy; <br />
INT cch; <br />
<br />
OpenClipboard(hWnd);<br />
EmptyClipboard(); <br />
<br />
cch=strlen(lpszString);<br />
hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (cch + 1) * sizeof(TCHAR)); <br />
if (hglbCopy == NULL) <br />
{ <br />
CloseClipboard(); <br />
MessageBox(hWnd,"errror on GlobalAlloc()","Error",MB_ICONERROR);<br />
return FALSE; <br />
} <br />
<br />
lptstrCopy = (LPTSTR)GlobalLock(hglbCopy); <br />
memcpy(lptstrCopy, lpszString, cch * sizeof(TCHAR)); <br />
lptstrCopy[cch] = (TCHAR) 0;
<br />
<br />
if(!GlobalUnlock(hglbCopy))
MessageBox(hWnd,"errror on GlobalUnlock()","Error",MB_ICONERROR);<br />
return FALSE; <br />
}<br />
<br />
if(!SetClipboardData(CF_TEXT, hglbCopy))<br />
{<br />
MessageBox(hWnd,"errror on SetClipboardData()","Error",MB_ICONERROR);<br />
return FALSE; <br />
}<br />
<br />
if(!CloseClipboard())<br />
{<br />
MessageBox(hWnd,"errror on CloseClipboard()","Error",MB_ICONERROR);<br />
return FALSE; <br />
} <br />
<br />
return TRUE;<br />
}
|
|
|
|
|
|
|
Here is one solution.
HANDLE cbData = ::GlobalAlloc(GMEM_MOVEABLE, STRING_SIZE + 1);
PTSTR pData = static_cast<ptstr>(::GlobalLock(cbData));
_tcscpy(pData, theString);
::GlobalUnlock(cbData);
COleDataSource *pODS = new COleDataSource;
pODS->CacheGlobalData(CF_TEXT, cbData);
pODS->SetClipboard();
Kuphryn
|
|
|
|
|
Hi,
I would like to develop a kind of news displaying app with a transparent window. Unfortunately my machine does not support alpha-blending overlays.
Therefore, I want to have an inactive always-on-top window that doesn't capture mouse events. Instead, all events shall be passed to the underlying windows, just as if my window would not exist.
Is that possible?
Thanks,
Chris
|
|
|
|
|
|
I have tried this. It doesn't work, because the currently active application still becomes inactive when I click into my window.
Any other suggestion?
Chris
|
|
|
|
|
I'm not sure - can we use the == operator on the basic_string templte, as in the following manner:
#include <iostream>
#include <string>
string s1 = "Hello" ;
string s2 = "Hello" ;
string s3 = "hell" ;
cout << (s1 == s2)
cout << (s1 == s3)
In some other languages (as in Java), == checks for equlity of memory location. Does basic_string have an overloaded == operator?
|
|
|
|
|
Yes basic_string does have the overloaded equals operator.
The reason Java checks equality of memory location is that in Java you only have references to objects - never the objects themselves (except for primitive types). In C++ you can have the object itself (in which case '==' should compare values) or a pointer to the object, in which case '==' compares memory addresses.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
|
Hiya I have been reading about com ports and sending data through them. But how do I set up a simple test, say sending one line of data through the comm port??
I know how to use CreateFile, WriteFile and ReadFile.
I have one computer. How can I do this??
Thanks.
|
|
|
|
|
If you call WaitForMultipleObjects with the bWaitAll param set to TRUE (indicating you want to wait for all, not just one, to become signaled), what is the return value if successful?
Is it WAIT_OBJECT_0?
Or some value between WAIT_OBJECT_0 and WAIT_OBJECT_0 + numobjs - 1?
Or something else?
|
|
|
|
|
Philnessosity wrote:
Or some value between WAIT_OBJECT_0 and WAIT_OBJECT_0 + numobjs - 1?
This one.
~RaGE();
|
|
|
|
|
i dont have enough knowledge of visual c++. Thats why iam here in front of the highly professional people like u to assist me.
Right now i am building an Video Conferencing application for a company. as iam heading to it what i want to know that what will be the hardware complications in the case and the prgramming one.
so i want excellent type of programmer to give me an idea actually how to head for it.what approach would be easy to use
|
|
|
|
|
I am creating an application which shares datafiles over a LAN of roughly 5 computers. I am positioning the datafiles on only one computer on this network, and allowing all the other computers access. If I were setting up a server, this would be no problem, for I could manage the files using CSemaphores, but there is no server. Can somebody let me know if there's an option using the CArchives, or any other classes, which would allow me to read and write to these files without interfering with other instances of my application? As an example, if two instances of the same application wish to write to the datafiles, I should only allow one, but I want the second application to patiently wait for access to the datafiles--the basic reader/writer problem, but over a network. Please let me know!!!
Thanks!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
No. One solution is to create (open) the files such that other processes may not write to the files or even read the files. There are no elegant solutions without a server managing a queue. The clients will need to loop through until the files are accessible.
Kuphryn
|
|
|
|
|
Hi,
I have problem adding a bitmap to the background of my SDI App.
I know how to add it in a dialog, but I have some problem adding it to a SDI App.
any ideas?
thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
One solution is to repaint the background in OnDraw(). Another solution add a handler to WM_ERASEBKGND.
Kuphryn
|
|
|
|
|
If I embed a CPropertySheet derived class as a child in a Cformview window. The controls of the initial page are not shown.
You can only see a blank page page.
If I select another tab and swith back to the first page,
the page is shown correctly
Since it's the second time I encounter this same problem,
I think there is someone who might have a solution for this.
thanks in advance.
|
|
|
|
|
use create instead of DoModal
includeh10
|
|
|
|
|
I am creating a RFC-868 compliant time server. It must support TCP/IP and UDP on server port 37. TCP/IP works fine. Each protocol dependent server runs in a separate thread and both threads always get created and appear to run fine.
The problem is on the UDP thread side. I wait for a packet to be rcvd on port 37 then transmit the current time as a long back to the requesting IP or computer. Though, it looks like I am sending the packet, I cannot capture it with a sniffer. There are no errors using the sendto() command and I even sent a bogus string as a test and still cannot see it on the network.
I have verified the socket is created and valid. The only thing I can think of is that maybe there is a conflict when binding the same adapter and IP address using two different protocols, UDP and TCP/IP. Is anyone aware of one? I am currently binding to INADDR_ANY which is supposed to allow me to receive from all network interfaces but I only transmit back to the IP address and port that I received in the request. One of my sniffers is monitoring all network adapters and doesn't see the response that I am sending. Another sniffer a coworker has for Linux did not see it either even though that is a private 2 computer network (crossover cable).
Hope someone can help.
|
|
|
|