Click here to Skip to main content
15,909,896 members
Home / Discussions / COM
   

COM

 
Questionreconnect Pin
ginjikun17-May-07 4:36
ginjikun17-May-07 4:36 
QuestionProblem occour when registering dll on win xp Pin
koolprasad200317-May-07 1:32
professionalkoolprasad200317-May-07 1:32 
AnswerRe: Problem occour when registering dll on win xp Pin
CPallini17-May-07 1:37
mveCPallini17-May-07 1:37 
AnswerRe: Problem occour when registering dll on win xp Pin
prasad_som17-May-07 2:04
prasad_som17-May-07 2:04 
Questionserver didnot register with DCom within the required timeout Pin
fulbright16-May-07 18:28
fulbright16-May-07 18:28 
QuestionUpdating Gridview properties by code Pin
aitch4216-May-07 9:35
aitch4216-May-07 9:35 
Questionfolder browser activex control and file/ folder list in tree format Pin
ravi kanthi16-May-07 3:50
ravi kanthi16-May-07 3:50 
AnswerRe: folder browser activex control and file/ folder list in tree format Pin
Dave Kreskowiak16-May-07 4:54
mveDave Kreskowiak16-May-07 4:54 
GeneralRe: folder browser activex control and file/ folder list in tree format Pin
leckey16-May-07 6:20
leckey16-May-07 6:20 
QuestionAdding Filter by Class ID Pin
Raja Bose C Leo15-May-07 21:29
Raja Bose C Leo15-May-07 21:29 
AnswerRe: Adding Filter by Class ID Pin
rjkg18-May-07 19:07
rjkg18-May-07 19:07 
QuestionRe: Adding Filter by Class ID Pin
Raja Bose C Leo18-May-07 22:04
Raja Bose C Leo18-May-07 22:04 
AnswerRe: Adding Filter by Class ID Pin
rjkg22-May-07 20:10
rjkg22-May-07 20:10 
GeneralGetting an ActiveX control to install (newbie question) Pin
Judah Gabriel Himango15-May-07 18:24
sponsorJudah Gabriel Himango15-May-07 18:24 
QuestionHow to properly initialise a COM/ActiveX component in C#? Pin
orinoco7715-May-07 6:12
orinoco7715-May-07 6:12 
QuestionNeed help to understand STA and MTA in COM Pin
Nandu_77b15-May-07 1:53
Nandu_77b15-May-07 1:53 
AnswerRe: Need help to understand STA and MTA in COM Pin
User 21559715-May-07 2:14
User 21559715-May-07 2:14 
QuestionWhat is proxy/strub in COM Pin
Nandu_77b15-May-07 1:46
Nandu_77b15-May-07 1:46 
AnswerRe: What is proxy/strub in COM [modified] Pin
User 21559715-May-07 2:18
User 21559715-May-07 2:18 
Questionregarding adding a filter Pin
Raja Bose C Leo14-May-07 3:04
Raja Bose C Leo14-May-07 3:04 
QuestionProblem: GetRecordInfoFromGuids Pin
viral_umang@hotmail.com14-May-07 1:55
viral_umang@hotmail.com14-May-07 1:55 
AnswerRe: Problem: GetRecordInfoFromGuids Pin
viral_umang@hotmail.com14-May-07 19:18
viral_umang@hotmail.com14-May-07 19:18 
QuestionInvalid Procedure call or argument in VB Client ? Pin
viral_umang@hotmail.com12-May-07 1:50
viral_umang@hotmail.com12-May-07 1:50 
AnswerRe: Invalid Procedure call or argument in VB Client ? Pin
Lim Bio Liong13-May-07 19:45
Lim Bio Liong13-May-07 19:45 
Hello Joshi,

I ran through your example and discovered one -possible- point of the E_INVALIDARG error occurs at the following line of code :

hr=::SafeArrayGetElement(*StudentArray,&i,(void*)ob2);

I declared the GetFirstRankStudent() method as follows :

HRESULT GetFirstRankStudent([in] SAFEARRAY(Student)* pStudentArray, [out, retval] Student* pStudent);

The SafeArrayGetElement() API makes a COPY of the required element of the array and so you must pass a pointer to an actual Student struct object (memory allocated for it already).

Your code above sends a NULL pointer as the 3rd parameter (i.e. ob2). This is the reason for the E_INVALIDARG error.

As a suggestion, I changed your code to as follows :

//Student *ob1=NULL,*ob2=NULL,*max=NULL;
Student ob2,*max=NULL;
Student ob1;
...
hr=::SafeArrayGetElement(*StudentArray,&lBound,(void*)&ob1);
max=&ob1;

if(FAILED(hr)) // this was where the original E_INVALIDARG appeared.
return hr;

for(long i=lBound+1;i < UBound; i++)
{
hr=::SafeArrayGetElement(*StudentArray,&i,(void*)&ob2);

if(FAILED(hr))
return hr;
else
{
if(ob2.Total>ob1.Total)
max=&ob2;
}
}

memcpy (pStudent, max, sizeof(Student));

return S_OK;

Best Regards,
Bio.
GeneralRe: Invalid Procedure call or argument in VB Client ? Pin
viral_umang@hotmail.com14-May-07 1:02
viral_umang@hotmail.com14-May-07 1:02 

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.