|
kidding?
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
|
|
|
Hello!
I am making MFC application which is divided into many DLL.
I am using STL and having problems with "access violation".
Should I use <afxtempl.h> instead, or is there anyway to fix that STL error? Your comments would be appriciated.
Sovann
|
|
|
|
|
Hello,
I think that the problem is not with STL or that the collections that the MFC provides will solve the problem.
What exactly is your problem?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Well, when all in one EXE, everything works just fine. Until we break into many DLL and pass/save pointer back/forth, we come to this "access violation". Most of the crash, we have invalid pointer such as 0xfeeefeee or 0xcccdcccd.
Sovann
|
|
|
|
|
Hello,
I don't know the exact meaning of those addresses, but they have something to do with uninitialized or already deleted pointers.
The rule of thumb is that you do not spread your memory management across different modules, that is, you should not allocate a block in your DLL A and free it in another module. Your problem might be here. Maybe you should make a copy of a memory block when it's saved across module boundraries.
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thank you for your comments. I would reconsider the memory management.
Sovann.
|
|
|
|
|
|
Thank you very much for your comments.
I have read them all. My problem was direct access to STL object in other module. Now I am working on it.
Thanks again. Have a nice day!
|
|
|
|
|
Hi all. I m using sockets to send file or strings in a TCP/IP simple client/server configuration. The question is, how do i let the sender differentiate b/w sending files and strings? I've read that people send ACK as a ascii character to acknowledge packets. Can i use this as a method to let the receiver know its receiving a file instead?
Pls help me!
|
|
|
|
|
You can use any kind of mutually agreed technique. So that both the client and server understand what happening.
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
i Dont remember any specific method IN TCP/IP for file or string
u can use a series of NULL char . Using the ACK might create
ambiguity in some case.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
ok thanks. I'll try out these methods. Btw, does anyone know of any good Winsock programs on this area? Cos i could only find tutorials on simple string sending but not on both.
|
|
|
|
|
Assuming that the files you are sending back and forth could contain arbitrary data, you can't use a simple marker character to signal a switch between sending strings and files.
A better approach is to define a message format that tells the receiver what type of data is coming. Here's an example:
struct Message {
enum {
String,
File
} Type;
unsigned int Length;
unsigned char Data[1];
}; The first value, Type , tells the receiver what kind of data is coming. The Length value specifies the amount of data to expect. The third value, Data , is actually just a placeholder for the actual data, which will be Length bytes long.
Software Zen: delete this; // <a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" rel="nofollow">Fold With Us!</a>[<a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" target="_blank" rel="nofollow" title="New Window">^</a>]
|
|
|
|
|
This sounds pretty hard to understand for me as i m new to sockets programming and also c++. Have only previously handled some simple programming in c. Could u pls provide me with more details or example?
Thanks for providing me with something anyway.
|
|
|
|
|
The way this works is that everything that is sent on the socket is a message. The sender will send a type, a length value, and the number of data bytes specified by the length. The receiver does the corresponding. It reads the type value, then the length, and then reads the number of data bytes specified by the length. Using this approach, you always know what type of data is being sent by the other end of the connection, and how big it is.
I would suggest making two simple test programs, a client program and a server program. You can run both of them at the same time on the same machine using IP address 127.0.0.1. You can then debug both of them simultaneously.
You might try looking at the articles in the Internet & Network Programming[^] section of Code Project. There are a number of good examples of this kind of approach.
Software Zen: delete this; // <a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" rel="nofollow">Fold With Us!</a>[<a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" target="_blank" rel="nofollow" title="New Window">^</a>]
|
|
|
|
|
In the midst of trying to develop a protocol which can differentiate string/file, i found out that the routine i modified from the website for send file was actually not working!
Below are part of my receiver code which i used for my CAsyncSocket. So i isolated the send string part and juz tried to produce a working part for file transfer. It seems that i have problem receiving the file when i tested e program with messagebox inside the routines. The new file was created at the destination but its just an empty file with 0 bytes.
void CSockDlg::OnReceive()<br />
{<br />
<br />
char* pBuf=new char[1025];<br />
int iBufSize=1024;<br />
int iRcvd;<br />
<br />
CString strLocalFileName;<br />
iRcvd=m_sConnectSocket.Receive(pBuf,iBufSize);<br />
pBuf[iRcvd] =NULL; <br />
strLocalFileName=pBuf;<br />
<br />
AfxMessageBox("U get this notification?");<br />
m_strFileName=strLocalFileName;<br />
BOOL bRet = GetFileFromRemoteSender(strLocalFileName );<br />
}
Pls help me out! Being stuck for days now.
|
|
|
|
|
Dear all,
I have tried to get the drive letter of specific USB device. Below is my code. I cannot get a proper return value from DeviceIoControl. Please help and advice me how to make it work. Thanks.
TCHAR diskletter[10];
for(char le='C';le<'T';le++)
{
drive.Format ("%c:",le);
if(GetDriveType(drive)==DRIVE_FIXED||GetDriveType
(drive)==DRIVE_REMOVABLE)
{
sprintf(diskletter,"\\\\.\\%c:",le);
HANDLE handle;
handle=CreateFile(diskletter, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,OPEN_EXISTING, NULL, NULL);
if (handle = INVALID_HANDLE_VALUE)
MessageBox("Open device failed");
else
{
STORAGE_DEVICE_DESCRIPTOR pDevDesc;
STORAGE_PROPERTY_QUERY Query;
DWORD dwOutBytes;
BOOL bResult;
Query.PropertyId= StorageDeviceProperty;
Query.QueryType = PropertyStandardQuery;
bResult=DeviceIoControl(handle,
IOCTL_STORAGE_QUERY_PROPERTY,
&Query, sizeof(STORAGE_PROPERTY_QUERY),
&pDevDesc, pDevDesc.Size,
&dwOutBytes,
(LPOVERLAPPED)NULL);
if(!bResult)
MessageBox("Get bus type failed");
if(pDevDesc.BusType == BusTypeUsb)
m_Editi=m_Editi+le;
CloseHandle(handle);
}
}
|
|
|
|
|
hi all!
my objective will be implement setup application (copy fonts and usp10.dll ) on Win XP.
i need replace file usp10.dll with new version but WinXP has a file protected mode. how could i deal that problem, please give me an advice.
|
|
|
|
|
Hello,
I recently upgraded my IDE to vc++2005 from vc++6.
I used to write windows services using the ATL Com AppWizard (and choose "service" as the server type).
My problem is that now, in vc++2005, I can't find any wizard for creating a windows service using only native (not managed) c++ code.
The only wizard exist in this new IDE creates a managed code project.
Do you know any way of creating windows services in vc++2005 using only unmanaged code?
Thanks.
|
|
|
|
|
Could someone please quide me to an example where MFC will open a text file (.txt) internally within the app. itself for viewing. I am using the VC++ MFC App. win. expoler to do this.
the path of the text file will always be fixed, so i need to know how to read the text file and display it in "read only format" internally on the right pane of the app. once the user clicks display in my UI
Thank you for you help!
|
|
|
|
|
There is a CP article here on a text file reading class that can even open UNICODE files. I would look for it on CP and use it in your project.
No shirt, no shoes, no brains, no service.
|
|
|
|
|
Thank you, i am searching for it now!
|
|
|
|