|
Using write function in stream classes you can only serialize classes having POD (Plain Old Data). If there are pointers in the class then this will not work. What I do is in each class which I want to serialize I write Read and Write functions which will do the serialization. If there is only POD then those function can use stream write function else I serialize each variable separately.
class Foo
{
void Read(std::istream& in);
void Write(std::ostream& out);
}
Then you can write serialization functions as
void Deserialize(std::iostream& stream, CMyClass& obj)
{
obj.Read(stream);
}
-Saurabh
|
|
|
|
|
Hi Saurabh
Many many thanks for suggestion!
Bye Manustone
|
|
|
|
|
If I have an HBITMAP, is it possible to use TextOut() or etc to write text to that bitmap?
|
|
|
|
|
|
Create a memory DC
Select the bitmap into it (saving the previously selected bitmap)
Render your text on the DC
Select the saved bitmap back into the DC (this un-selects your bitmap from the DC)
Destroy the DC
The only catch here is, if the HBITMAP is not a DIBSection, then the DC will need to be
compatible with the bitmap or selecting the bitmap into the DC can fail.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes its possible you need to a handle to DC(Createompatibledc) and for other steps see Mark's answer.
|
|
|
|
|
Hi all,
I am trying to convert a long file path ( more than 255 chars, in UNC format) using GetShortPathNameW API. But It fails, saying that
"The filename, directory name, or volume label syntax is incorrect."
Anybody knows what is issue here?
|
|
|
|
|
Probably the filename or the directory name or the volume label syntax is incorrect, I suppose.
BTW have you read the following note (from MSDN [^]):
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I have used GetShortPathNameW (unicode version ) only
sample path is as follows:
"\\?\UNC\server_ip\ONTAP_ADMIN$\vol\vol0\home\testdir4\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"
modified on Wednesday, April 23, 2008 10:25 AM
|
|
|
|
|
Well, I get error 3 (the system cannot find the path specified), that is quite different. How do you call the function?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Here is the sample code
<br />
DWORD dw =0;<br />
wstring m_UNCPath = L"Long file name";
<br />
long length = GetShortPathNameW(m_UNCPath.c_str(), NULL, 0);<br />
DWORD dwerror = GetLastError();<br />
<br />
<br />
length += 2;<br />
wchar_t* buffer = new wchar_t[length];<br />
<br />
dwerror= GetShortPathNameW(m_UNCPath.c_str(), buffer, length); <br />
|
|
|
|
|
Some updates here are
If the path is given like
"\\?\c:\..."
things works
but for path
"\\?\UNC\c:\..."
things fails.
Most important I want to get shortpath name over network
so my path becomes
"\\?\UNC\ip_address\..."
Here things fails badly.
|
|
|
|
|
My test:
void main()
{
WCHAR szShort[MAX_PATH];
DWORD dw =0;
wstring m_UNCPath = L"C:\\Documents and Settings\\01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234.txt";
long length = GetShortPathNameW(m_UNCPath.c_str(), szShort, MAX_PATH);
}
resulting value of szShort :
"C:\DOCUME~1\012345~1.TXT"
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Please recheck your path. I guess it's less then 255 chars.
|
|
|
|
|
Damn, you're right, Windows truncated the name...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
See you can not create a long file path simply in windows explorer.It is not supported. You need to call apis like CreateDirectoryEx and CreateFileW to create such path and write a file inside it.
|
|
|
|
|
Hi! I have some transport which based on winsock. Client(FTPS) send to me some data over SSL, and i receive it with (for example):
<br />
...<br />
if (WSARecv(AcceptSocket, &DataBuf, 1, &RecvBytes, &Flags, &AcceptOverlapped, NULL) == SOCKET_ERROR){<br />
if (WSAGetLastError() != WSA_IO_PENDING)<br />
printf("Error occured at WSARecv()\n");<br />
}<br />
...<br />
how can i decrypt received data in DataBuf, if i have certificate, puclic and private keys?
|
|
|
|
|
|
helo,
I want to write socket client application by using c or c++ in window without using any Winsock or MFC class.
how do i achieve it.
I search it but not getting exactly .
Regards,
Amit
|
|
|
|
|
Are you kidding?
AFAIK even Cygwin uses Winsock library.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
There are many network libraries out there. For instance, take a look at Boost Asio[^]
|
|
|
|
|
Don't you have to write your own communication interface between the TCP/IP stack and your software ? or something like that ?
|
|
|
|
|
|
See here[^] does helpful?
|
|
|
|
|
Does it seem reasonable to load a 40-sec WAV to a 'static' DirectSound secondary buffer to play as my game background-music ?
If not, why not ?
The other option, AFAIK, is having 'streaming' buffer for that. Which will be more complicated programmatically.
|
|
|
|