Click here to Skip to main content
15,885,546 members
Home / Discussions / COM
   

COM

 
Question#pragma pack Pin
anu_8820-Jul-06 23:01
anu_8820-Jul-06 23:01 
AnswerRe: #pragma pack Pin
Steve S20-Jul-06 23:32
Steve S20-Jul-06 23:32 
GeneralRe: #pragma pack Pin
anu_8821-Jul-06 0:32
anu_8821-Jul-06 0:32 
Questionsafearray of user defined structure store in variant Pin
rudo3220-Jul-06 21:31
rudo3220-Jul-06 21:31 
AnswerRe: safearray of user defined structure store in variant Pin
Aamir Butt25-Jul-06 0:29
Aamir Butt25-Jul-06 0:29 
AnswerRe: safearray of user defined structure store in variant Pin
Tim Paaschen25-Jul-06 2:42
Tim Paaschen25-Jul-06 2:42 
QuestionEcxel.dll is not working Pin
ersinsivaz20-Jul-06 10:00
ersinsivaz20-Jul-06 10:00 
Questionsafearray access returns junk pls help Pin
nikhil_ag198520-Jul-06 2:07
nikhil_ag198520-Jul-06 2:07 
Hi All,
Im writing a dll in ATL COM called by a vb.net client. the client passes a 2d integer array when it calls MyMethod.
i have tow problems
I. i have trouble accessing the values in the array passed, i get junk values. this is the code.
<br />
STDMETHODIMP ExposedATLClass::MyMethod(SAFEARRAY **psa)<br />
{<br />
	AFX_MANAGE_STATE(AfxGetStaticModuleState())<br />
	long arrlengthx,arrlengthy;<br />
	long **myarray;<br />
	int indexx,indexy;<br />
	try<br />
	{<br />
		arrlengthx=(*psa)->rgsabound[0].cElements;<br />
		arrlengthy=(*psa)->rgsabound[1].cElements;<br />
		myarray=(long**)malloc(arrlengthx*sizeof(long**));	<br />
                for(long tempvar=0;tempvar<=arrlengthx;tempvar++)<br />
		{<br />
			myarray[tempvar]=(long*)malloc(arrlengthy*sizeof(long*));<br />
		}<br />
		SafeArrayAccessData(*psa,(void**)myarray);	//accessing data stored in safearray by obtaining pointer<br />
		char details[100];<br />
		for(int tempx=0; tempx<=arrlengthx; tempx++, indexx++, indexy=0)<br />
	{<br />
			for(double tempy=0; tempy<=arrlengthy; tempy++, indexy++)<br />
			{<br />
					sprintf(details,"%d %d %d",indexx,indexy,myarray[indexx][indexy]);<br />
					this->Error_Logger(details);	//this function prints 'details' in a txt file.<br />
			}<br />
		}<br />
	}<br />
	catch(CException ex)<br />
	{<br />
		char error[300];<br />
		ex.GetErrorMessage(error,300);<br />
		this->Error_Logger(error);<br />
		ex.Delete();<br />
	}<br />
	return S_OK;<br />
}<br />

in the program

SafeArrayAccessData(*psa,(void**)myarray); returns success

other methods i've used to access data are (replace the line "SafeArrayAccessData(*psa,(void**)myarray);" with code below )
1. using SafeArrayGetElement
<br />
long ai[2]={0,0}<br />
for(int temx=0;temx<=arrlengthx;temx++,ai[0]++)<br />
{<br />
	for(int temy=0;temy<=arrlengthy;temy++,ai[1]++)<br />
{<br />
		SafeArrayGetElement(*psa,ai,&myarray[temx][temy]);<br />
	}<br />
}<br />


here SafeArrayGetElement(*psa,ai,&myarray[temx][temy]); returns index out of bounds

2. using safearraylock/unlock
<br />
/*SafeArrayLock(*psa);	<br />
*myarray=(long*) (*psa)->pvData;<br />
SafeArrayUnlock(*psa);*/<br />


both lock and unlock returned success

all methods return this junk value for myarray[indexx][indexy] -842150451
the values of indexx and indexy are correct and so are the boundaries.

II. my other problem.. no exception is logged.

where am i wrong. pls help
Thanks in advance
Nikhil
QuestionGUID [modified] Pin
RRRB20-Jul-06 0:09
RRRB20-Jul-06 0:09 
AnswerRe: GUID Pin
nikhil_ag198520-Jul-06 2:14
nikhil_ag198520-Jul-06 2:14 
GeneralRe: GUID Pin
RRRB20-Jul-06 2:26
RRRB20-Jul-06 2:26 
AnswerRe: GUID [modified] Pin
sudeesh26-Jul-06 3:07
sudeesh26-Jul-06 3:07 
QuestionPlease help. Problem with including .idl file [modified] Pin
Kiran Pinjala19-Jul-06 21:35
Kiran Pinjala19-Jul-06 21:35 
AnswerRe: Please help. Problem with including .idl file Pin
Steve S19-Jul-06 21:59
Steve S19-Jul-06 21:59 
GeneralRe: Please help. Problem with including .idl file Pin
Kiran Pinjala19-Jul-06 23:47
Kiran Pinjala19-Jul-06 23:47 
Questionhow to use activeX inside ActiveX [modified] Pin
Chetan Sheladiya19-Jul-06 19:38
professionalChetan Sheladiya19-Jul-06 19:38 
AnswerRe: how to use activeX inside ActiveX Pin
Prakash Nadar1-Aug-06 1:18
Prakash Nadar1-Aug-06 1:18 
Questionhow to login Pin
With_problem19-Jul-06 17:48
With_problem19-Jul-06 17:48 
Questionstarting problem with Netmeeting sdk program Pin
Kiran Pinjala19-Jul-06 2:28
Kiran Pinjala19-Jul-06 2:28 
Questionstarting problem with Netmeeting sdk program Pin
Kiran Pinjala19-Jul-06 2:43
Kiran Pinjala19-Jul-06 2:43 
Questiona way around constructor arguments Pin
nikhil_ag198518-Jul-06 21:07
nikhil_ag198518-Jul-06 21:07 
QuestionProblem in debugging COM+ DLL Pin
Findingnimmo18-Jul-06 20:37
Findingnimmo18-Jul-06 20:37 
QuestionDifficulty in creating object of IMAPI Pin
kanduripavan18-Jul-06 18:48
kanduripavan18-Jul-06 18:48 
AnswerRe: Difficulty in creating object of IMAPI Pin
Steve S18-Jul-06 21:48
Steve S18-Jul-06 21:48 
GeneralRe: Difficulty in creating object of IMAPI Pin
kanduripavan19-Jul-06 20:22
kanduripavan19-Jul-06 20:22 

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.