Karl Blessing
Programmer
I need to figure out how I can download a file into memory. the file comes in as 256byte chunks (char[256]) which is written each time to a file, what I want to acheive is to write these chunks each time into a SafeArray without knowing the filesize ahead of time, then pass that SafeArray out to VB(this VC++ project is an ActiveX control) I've looked at 2 articles ( Q154172 being the first one) on MSDN, one telling howto pass Binary Data between an activeX control and VB (which was a fixed 512byte SafeArray as a variant, and the SafeArray was created in VB then passed to vC++), The other was how to pass a SafeArray of Strings (char arrays) in as a VARIANT* Again only problem with that is that it seemed to be a fixed size, and it was passing from VB into VC++.<br><br>At the moment this is the regular loop that reads data from the server, and appends it to a file as each chunk comes in, Might use this as a reference, to modify slightly to append into a Array that is passable to VB if i can.<br><br><br> while(1){<br> if(timeOut >0){<br> if(WaitForReceive(timeOut,0) != CUT_SUCCESS){<br> error = 3;<br> break;<br> }<br> }<br> count = Receive(data,sizeof(data));<br><br> //check to see if the connection is closed<br> if(count == 0)<br> break;<br> //if an error then break<br> if(count == SOCKET_ERROR){<br> error = 4;<br> break;<br> }<br>while(pause) { }<br> //write the the file<br> if(fwrite(data,sizeof(char),count,fptr) < (unsigned int)count){<br> error = 5;<br> break;<br> }<br><br> //count the bytes copied<br> *bytesReceived += count;<br><br> //send notify<br> if(ReceiveFileStatus(*bytesReceived)==FALSE){<br> error = 6;<br> break;<br> }<br> }<br><br><br>(goal is this ActiveX control is gona serve as the client/server control that'll send bitmap or whatever kind of data the VB programmers are going to use, instead of saving to a file they want to save to memory and pass it back out to VB so that they can use it immediatly and so that its never stored on harddisk) <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)