-
How do you convert a C++ string to a VB
[Originally posted by Tich]
How do you convert a pointer to a C++ (null terminated) string into a nomal VB string?
-
RE: Convert a C++ string to VB
[Originally posted by FreeVBCode.com]
You may find http://support.microsoft.com/support/kb/articles/Q187/9/12.ASP helpful.
-
Re:RE: Convert a C++ string to VB
[Originally posted by Tich]
What i realy wanted to do was replace some 'C' code with a piece of VB.ÿ The 'C' code was :-
// Get a VB string from a text pointer
STDAPI_(BSTR) GetStringFromLPSTR(LPSTR tptr)
{
BSTR rptr;
char tbuf = '\0';
ÿ if(!tptr) {
ÿ ÿ ÿ rptr = SysAllocString((OLECHAR *)&tbuf);
ÿ ÿ ÿ }
ÿ else {
// Why do it by length? Because SysAllocString looks for a double
// null - which may not be present
ÿ ÿ ÿ rptr = SysAllocStringByteLen(tptr, lstrlen(tptr));
ÿ ÿ ÿ }
//ÿ MessageBox(NULL,(LPSTR)rptr,NULL,0);
ÿ return(rptr);
}
It works fine, but i wanted the functionality within VB (i dont want to have to distribute a seperate 'C' Dll)
-
Re:Re:RE: Convert a C++ string to VB
[Originally posted by FreeVBCode.com]
I have added a code example to do this.ÿ See <A HREF = 'http://www.freevbcode.com/ShowCode.Asp?ID=2643'>http://www.freevbcode.com/ShowCode.Asp?ID=2643</A>.
Note that this example is for Unicode strings.ÿ I don't know if this is what is used in C.ÿ But if it's not, there are also instructions for how to change the code.
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks