|
-
February 23rd, 2000, 08:15 PM
#7
Re: Calling VB DLL from C
well, i have done a sample program using #import to call the VB DLL and it works. Can you explain to me what do you mean by static linking if we use the #import to call the DLL? Am I doing it the right way??TQ
Below are the codes on how i call the DLL from my C console application.
++++++++++++++++++++++++++++++++++++++++++
include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#import "f:\IVR\IVR program\convert1.dll" no_namespace
void main()
{
//initialize variable for bstr
BSTR bstrDesc;
BSTR st1;
char bufin[10];//input variable
char bufout[10];//output variable
BSTR buffinbstr = NULL;
WCHAR buffer1[512];
try
{
CoInitialize(NULL);
//Request input to be send
printf("Enter string");
scanf("%s",&bufin);
//Tukar ANSI to UNICODE
MultiByteToWideChar(CP_ACP,0,bufin,-1,buffer1,512);
buffinbstr = SysAllocString(buffer1);
_convert1Ptr ptr;
ptr.CreateInstance(_uuidof(convert1));
st1 =ptr->ConvertUpper(buffinbstr);
//st1 = st;
//Tukar UNICODE to ANSI
WideCharToMultiByte(CP_ACP,0,st1,-1,bufout,80,NULL,NULL);
//print output frm VB
printf("sucess output ,%s \n",&bufout);
}
catch(_com_error &e)
{
bstrDesc = e.Description();
}
SysFreeString(buffinbstr);
CoUninitialize();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|