|
how to call add(int i,int j) function in a mfc dll from vb application.
I have done all the steps to include c++ MFC dll to vb project.
It is working fine with function calls with no arguments like show();
But it returning garbage value when i call add(5,4) which passes arguments to the function.
my code in vb is like this:
Private Declare Function AddValues Lib "dllmfc.dll" (i,j) As Integer
Private Sub btnadd_Click()
Dim ans As Integer
a = AddValues(5, 4)
MsgBox (a)
End Sub
please tell me where i am wrong.
punit singh
|
|
|
|
|
What does AddValues() look like?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi thanks
Addvalues(i,j) add i & j then returns i+j.
|
|
|
|
|
punit singh wrote: Addvalues(i,j) add i & j then returns i+j.
This is not what AddValues() looks like.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi David,
I have created this AddValues(int i, int j) in .dll file and i am exporting this
funtion to use in VB appication.
It is in dll like this;
int _stdcall Addvalues(int i, int j)
{
return i+j;
}
it is c++ mfc dll.
punit singh
|
|
|
|
|
punit singh wrote: please tell me where i am wrong
Probably by using VB
Ok, more seriously: did you check that the function has a standard calling convention ? (There should be a __stdcall just before the function name).
In C++ you would have a crash if calling conventions are not the same but I don't know how VB manages it.
|
|
|
|
|
Two problems I see...
First, you have
Dim ans as Integer but then you use
a = AddValues(5,4)
Secondly, the argument you pass to MsgBox should be a string, and you're passing an integer.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
ya thanks
but
I did
Dim ans as Integer
ans=AddValues(5,4)
MsgBox ans
MsgBox converts it as string automatically. It is right.
as if i write like
ans=9
MsgBox ans
then it prints 9 so it converts automatically.
But still I am not getting right answet it is returning -5714 as answer and it should return 9.
punit singh
|
|
|
|
|
thanks
ya I have used _stdcall befor function name.
punit singh
|
|
|
|
|
krmed wrote: ...you're passing an integer.
Nothing wrong with that.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
ya I got the answer.
here is the code:
Private Declare Function AddValues Lib "dllmfc.dll" (i,j) As Integer
Private Sub btnadd_Click()
Dim ans As Integer
a = AddValues(5, 4)
MsgBox (a)
End Sub
and problem is with this line
Private Declare Function AddValues Lib "dllmfc.dll" (i,j) As Integer
I have to write (ByVar a as Integer,ByVar a as Integer) instead of (i,j)
|
|
|
|
|
punit singh wrote:
I have to write (ByVar a as Integer,ByVar a as Integer) instead of (i,j)
That's because ByRef is the default used by VB.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
i want to create a bar that contain shortcuts, this bar is similar to the bar of windows (left bar), each click over element in the window generate new shortcuts on this bar, exactly like windows.
So, i must download an file and add it to my project ? or i have simply to play with the differents composant of visual c++ ? and how ?
Thank u for responding
GraviTy Woks
|
|
|
|
|
are you wanting to create a toolbar ?
|
|
|
|
|
Thank u for your rapid answer, finally i found the solution of my litte problem.
It was the windows explorer bar, u can see the example in this page
|
|
|
|
|
Hello!
I open an ACCESS table, this is a very big table, for open this table I use a OLE DB
with ADO Classes wrapping...but...memory problem!
I open a big table with this istruction:
<br />
m_pRecordset->Open(m_strQuery.GetBuffer(), _variant_t((IDispatch*)mpdb, TRUE),<br />
adOpenKeyset, adLockOptimistic, adCmdTable);<br />
m_strQuery.ReleaseBuffer();<br />
<\endcode><br />
<br />
Where m_pRecordset is a _RecordsetPtr.<br />
<br />
When I performe the open istruction the memory comes literally eaten.<br />
The program in order to execute the table begins to have use of of all the RAM memory.<br />
<br />
Ther'is a BUG in the ADO Provider or other FIXED ?<br />
Any Idea ??:(<br />
<br />
Thanks in advance <br />
<br />
<div class="ForumSig">Too many plans make the health badly!!</div>
|
|
|
|
|
Hi all,
Whats the difference between creating project in
1)MFC AppWizard(exe)
and
2)Win32 Application
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
The former uses MFC while the latter does not. The difference is for the developer, not the end-user.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
If this Question is asked in interview
Diff bet MFC app wiz and Win 32 app?
What could be best answer?
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
MFC's are wrapper classes around the Win32 API. So it ease you the developpement of a GUI based application. If you start a win32 app, you'll need to write everything yourself.
|
|
|
|
|
vibindia wrote: If this Question is asked in interview
Diff bet MFC app wiz and Win 32 app?
What could be best answer?
I would seriously question why the interviewer would ask such a silly question. At the very least, it is comparing apples and oranges.
The MFC App Wizard is part of the IDE that creates a boiler-plate MFC application. A Win32 Application is just that - an application written with the Win32 SDK.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello
I have question About RealVNC
I Want To know what is the main function that sends Display Information to
the client application
thank you
|
|
|
|
|
Hello cumunity,
is there any way to check what filetype is reading,
i read all files from a folder, and i need to know
what types are in them!?
The only way i know is to read the character
from the end to first occurrence of an point, with
Right(int nNum); and check for the extension,
if its .html or .htm or .js or .txt or .jpg etc.
Is there any bether way to check for file type?
regards
break;
|
|
|
|
|
The PathFindExtension() shell API will find the extension for you.
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hello Mark,
thanks for answer, that helps me!
regards
break;
|
|
|
|