Click here to Skip to main content
15,890,527 members
Home / Discussions / COM
   

COM

 
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 
GeneralRe: Invalid Procedure call or argument in VB Client ? Pin
Lim Bio Liong14-May-07 2:21
Lim Bio Liong14-May-07 2:21 
QuestionQuery Interface from Another Interface of Same Com Server Pin
georgekjolly11-May-07 4:47
georgekjolly11-May-07 4:47 
AnswerRe: Query Interface from Another Interface of Same Com Server Pin
Roger Stoltz11-May-07 5:08
Roger Stoltz11-May-07 5:08 
GeneralRe: Query Interface from Another Interface of Same Com Server Pin
georgekjolly11-May-07 5:21
georgekjolly11-May-07 5:21 
GeneralRe: Query Interface from Another Interface of Same Com Server Pin
Roger Stoltz11-May-07 9:37
Roger Stoltz11-May-07 9:37 
GeneralRe: Query Interface from Another Interface of Same Com Server Pin
georgekjolly11-May-07 18:35
georgekjolly11-May-07 18:35 
QuestionWindows services Pin
tantoun11-May-07 4:17
tantoun11-May-07 4:17 
Questionhow to show select file and directory dialog in c&api program Pin
zhongwenjia11-May-07 3:57
zhongwenjia11-May-07 3:57 
QuestionDOS/16M: [2] not a DOS/16M executable Pin
TooLeeDiN10-May-07 22:11
TooLeeDiN10-May-07 22:11 
AnswerWrong forum? Pin
CPallini11-May-07 0:49
mveCPallini11-May-07 0:49 
QuestionHow to pass an array to a COM method accept a VARIANT * Pin
songll10-May-07 8:27
songll10-May-07 8:27 
AnswerRe: How to pass an array to a COM method accept a VARIANT * Pin
prasad_som11-May-07 4:11
prasad_som11-May-07 4:11 
QuestionHuman Readable HRESULTs Pin
Phil Harding10-May-07 0:53
Phil Harding10-May-07 0:53 
AnswerRe: Human Readable HRESULTs Pin
Mike Dimmick10-May-07 1:47
Mike Dimmick10-May-07 1:47 
AnswerRe: Human Readable HRESULTs Pin
Roger Stoltz10-May-07 1:56
Roger Stoltz10-May-07 1:56 
AnswerRe: Human Readable HRESULTs Pin
User 21559710-May-07 2:42
User 21559710-May-07 2:42 

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.