Click here to Skip to main content
15,886,919 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien23-Aug-11 0:10
lenourien23-Aug-11 0:10 
GeneralRe: Weird problem using C++ dll from vb6 Pin
Richard MacCutchan23-Aug-11 0:12
mveRichard MacCutchan23-Aug-11 0:12 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien23-Aug-11 2:55
lenourien23-Aug-11 2:55 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien23-Aug-11 5:05
lenourien23-Aug-11 5:05 
AnswerRe: Weird problem using C++ dll from vb6 Pin
MicroVirus23-Aug-11 5:24
MicroVirus23-Aug-11 5:24 
GeneralRe: Weird problem using C++ dll from vb6 Pin
Richard MacCutchan23-Aug-11 5:51
mveRichard MacCutchan23-Aug-11 5:51 
AnswerRe: Weird problem using C++ dll from vb6 Pin
MicroVirus23-Aug-11 5:18
MicroVirus23-Aug-11 5:18 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien23-Aug-11 13:33
lenourien23-Aug-11 13:33 
Hello all,

to answer your questions:
1- I'm using static so that the arrays are automatically initialized when declared, specifically the multi dimentional arrays. Without that I get error messages.

2- I'm using pVal.pbstrVal because it is an array of BSTR that uses VT_BYREF. According to my research releasing the variant won't release the string because it is byref so I have to do it myself. I read that in several places so I just assumed it was correct.

3-psa i initialised somewhere in the code and destroyed in the end and they both worked correctly. Here is the initialisation code:
pSA= SafeArrayCreate(VT_BSTR,1,aDim);

if (pSA != NULL) {

BSTR element = SysAllocString((BSTR)words[low]);

unsigned int length = SysStringByteLen(element);
BSTR wcElement = NULL;

wcElement = SysAllocStringByteLen(NULL, length*2); //SysAllocStringLen(NULL, length*2);
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,(LPCSTR)element
, -1, (LPWSTR)wcElement, length*2);

	for(i = 0; i < wordcnt[low]; i++) {

		if (hr= SafeArrayPutElement (pSA, &arrIndex, wcElement)){
			SafeArrayDestroy(pSA); // does a deep destroy on error
		}

		SysFreeString (wcElement); 
		SysFreeString (element);
		arrIndex++;
		
        } 

As you said (microvirus) the problem is that I declare everything as static. although it is not necessary for most I still have the problem with multidimensional arrays.
Here is an example. I have 2 arrays
int nb[81][8];
int nrnb[81];
at some point in my code I have
nb[i][nrnb[i]++] = p;

when the arrays are declared static there is no problem but if not, I get error telling me it can't be accessed.

I know I could use a for loop on those arrays and set everything to 0 and it works but I assume C++ allows for more efficient ways.

I also tried to use new int* nrnb[81] and new int** nb[81][8] but then my code refuses to use them because of pointers problems.

So the solution to the previous problem is don't use static.

The new problem is should I use a for loop on the multidimensional arrays?

Also I know everybody says multidimensional arrays are hell and it's better to use array[width x height] or use vector but I don't really want to do that, the reason being hours of rewritting the code involved and believe me, for me c++ is excruciating pain.

Thanks again
QuestionRe: Weird problem using C++ dll from vb6 Pin
MicroVirus23-Aug-11 15:22
MicroVirus23-Aug-11 15:22 
AnswerRe: Weird problem using C++ dll from vb6 Pin
lenourien24-Aug-11 4:17
lenourien24-Aug-11 4:17 
AnswerRe: Weird problem using C++ dll from vb6 Pin
MicroVirus24-Aug-11 17:41
MicroVirus24-Aug-11 17:41 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien25-Aug-11 1:31
lenourien25-Aug-11 1:31 
GeneralRe: Weird problem using C++ dll from vb6 Pin
MicroVirus25-Aug-11 3:25
MicroVirus25-Aug-11 3:25 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien25-Aug-11 12:39
lenourien25-Aug-11 12:39 
QuestionWTSSendMessage fails as RPC Server is unavailable Pin
Arun Parthasarathy22-Aug-11 1:24
Arun Parthasarathy22-Aug-11 1:24 
AnswerRe: WTSSendMessage fails as RPC Server is unavailable Pin
Tony Richards25-Aug-11 13:05
Tony Richards25-Aug-11 13:05 
QuestionConverting ADO data types into C++ data types Pin
Bahram198420-Aug-11 0:47
Bahram198420-Aug-11 0:47 
AnswerRe: Converting ADO data types into C++ data types Pin
John Schroedl22-Aug-11 3:28
professionalJohn Schroedl22-Aug-11 3:28 
QuestionInheriting a template class Pin
Subin Mavunkal17-Aug-11 1:43
Subin Mavunkal17-Aug-11 1:43 
AnswerRe: Inheriting a template class Pin
George L. Jackson9-Sep-11 12:13
George L. Jackson9-Sep-11 12:13 
Questionc++ function name parameter problem Pin
ali_zdn14-Aug-11 3:11
ali_zdn14-Aug-11 3:11 
AnswerRe: c++ function name parameter problem Pin
Richard MacCutchan14-Aug-11 7:03
mveRichard MacCutchan14-Aug-11 7:03 
QuestionProject Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Andraw Tang5-Aug-11 11:16
Andraw Tang5-Aug-11 11:16 
AnswerRe: Project Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Richard MacCutchan5-Aug-11 22:32
mveRichard MacCutchan5-Aug-11 22:32 
GeneralRe: Project Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Andraw Tang8-Aug-11 4:37
Andraw Tang8-Aug-11 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.