Avatar of firearmz
firearmz
Flag for Germany

asked on 

BITS->AddFile Method .. or how to copy some lpwstr to lpwcstr ?

Hello,

i have a program which creates a BITS Job.
During the initialization i'm Adding Files to the BITS Job using the AddFile Method ( see http://msdn.microsoft.com/en-us/library/aa363017(VS.85).aspx ).

My problem is quite weird just look at the sample code below.
NOTE: Read the comments carefully !

Target:
I wan't to get rid of using my "bits_add_files" helper function.


with best regards,

FireArmz
/*
      Working Way! but slow as hell ..
*/
 
int bits_add_files(LPWSTR str_local, LPWSTR str_remote, int i_Index) {
	gbJob->AddFile(str_remote,str_local);
	return i_Index;
};
 
 
int cool_function(...) {
  
 wstring local, remote; 
 
 while (..) {
 
  lpstr_local = (LPWSTR) malloc ( sizeof(LPWSTR) *local.length());
  lpstr_local = (wchar_t*)local.c_str();
 
  lpstr_remote = (LPWSTR) malloc ( sizeof(LPWSTR) *remote.length());
  lpstr_remote = (wchar_t*)remote.c_str();
 
   bits_add_files(lpstr_local,lpstr_remote,index);
 
 };
 
};
 
 
/* 
   WANTED WAY .. i wan't to get rid of calling "bits_add_files()"
 */
 
int cool_functions(...) {
  
 wstring local, remote; 
 
 while (..) {
 
  lpstr_local = (LPWSTR) malloc ( sizeof(LPWSTR) *local.length());
  lpstr_local = (wchar_t*)local.c_str();
 
  lpstr_remote = (LPWSTR) malloc ( sizeof(LPWSTR) *remote.length());
  lpstr_remote = (wchar_t*)remote.c_str();
 
   gbJob->AddFile(lpstr_remote,lpstr_local);
/*
  This does compile well BUT after "cool_function" finished, the Files Array of BITS ( gbjob ) is EMPTY!
  I'm guessing that i have to somehow copy the memory over to the AddFile Call.
  AddFile Returns "E_INVALIDARG".
*/
 
 };
 
};

Open in new window

Editors IDEsMicrosoft Development

Avatar of undefined
Last Comment
firearmz

8/22/2022 - Mon