473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Handling C++ DLL string pointer

All,

I have a C++ DLL that has the following function in it.

LONG MYAPI myApi_FunctionName
(
LONG lDSType, /* i Source type */
LPWSTR lptstrSource, /* io Source name */
LONG lDSLength, /* i Length of lptstrSource */
LPCWSTR lpctstrCat, /* i Catalogue */
LPCWSTR lpctstrSubj /* i Subject */
);

I have the following declared in my VB2005 module.

Public Declare Unicode Function myApi_FunctionName Lib "mydll.dll" (ByVal lDSType As Integer, _
ByRef lptstrSource As Integer, _
ByVal lDSLength As Integer, _
ByVal lpctstrCat As String, _
ByVal lpctstrSubj As String) As Integer

If I declare lptstrSource as Integer, I get a numeric value. I believe it is the pointer address. The question is, how do I get the actual "Source name" string (i.e. lptstrSource)?
I have tried passing lptstrSource as String. However, it is always empty.

Thanks,

alex

Aug 28 '06 #1
2 1239
>If I declare lptstrSource as Integer, I get a numeric value. I believe it is the pointer address. The question is, how do I get the actual "Source name" string (i.e. lptstrSource)?
>I have tried passing lptstrSource as String. However, it is always empty.
The string should be passed ByVal. If it's an output parameter,
consider using the StringBuilder type instead.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Aug 28 '06 #2
Mattias,

It works perfectly. Thanks a lot.

^_^

alex
"Mattias Sjogren" <ma********************@mvps.orgwrote in message
news:eb**************@TK2MSFTNGP02.phx.gbl...
If I declare lptstrSource as Integer, I get a numeric value. I believe it
is the pointer address. The question is, how do I get the actual "Source
name" string (i.e. lptstrSource)?
I have tried passing lptstrSource as String. However, it is always empty.

The string should be passed ByVal. If it's an output parameter,
consider using the StringBuilder type instead.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Aug 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sean W. Quinn | last post by:
Hey folks, I have a question regarding file handling, and the preservation of class structure. I have a class (and I will post snippets of code later in the post) with both primitive data...
12
by: Vaca Louca | last post by:
Hello, I write an ISAPI authentication module which uses Berkeley DB and want it to be as efficient as possible. Both ISAPI and BerkeleyDB use arrays of chars (char *) to pass and receive...
12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
5
by: Chathu | last post by:
Hello everyone........... I have a problem on retriving a content of a binary file I wrote into. My program user structures, dynamic allocation of memory and files. I take the infomation into a...
1
by: Fr?d?ric Ledain | last post by:
Hi. I have to design new API, which some of them have to return a string. I have mixed feelings about the various strategies I can choose : 1. API(char *s, long *size) => the client gives a...
2
by: Susan Baker | last post by:
Hi, I am writing a Win32 DLL. I want to be able to handle any SEGVs (segmentation violations) gracefully, by using an error handler of sorts. Currently, if a user of my DLL (typically a VB...
34
by: Chad | last post by:
Given the following code that achieves no useful purpose: #include <string.h> #include <stdio.h> #include <string.h> int manip(char *str) { size_t len = strlen(str)-1; if(len >= 3) {
94
by: Chad | last post by:
On to top of page 163 in the book "The C Programming Langauge" by K & R, they have the following: char *strdup(char *s) { char *p; p=(char *)malloc(strlen(s)+1); if( p != NULL) strcpy(p,s):...
8
by: RichardOnRails | last post by:
I have a Stack class that works fine. In particular, when it encounters an error, it cout's a msg and exits. However, I'd like to change it to report the error and continue with dummy data as...
9
by: arnuld | last post by:
Can anyone point me to some online/offline document on error handling in C ? I am doing some Socket Programming in C and feeling a lots of difficult in error handling :( Also some time ago...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.