|
-
Jun 13th, 2002, 03:54 PM
#1
Thread Starter
Frenzied Member
Lpwstr
I have a LPWSTR with a value and I want to convert it to char* or string.
Is there a simple function to do this?
Last edited by wey97; Jun 14th, 2002 at 12:28 AM.
-
Jun 14th, 2002, 10:21 AM
#2
Monday Morning Lunatic
LPWSTR is actually wchar_t* (or the equivalent of).
You can use this raw under 2000 (it's a Unicode string), but for 98 you need to convert it. Search the forum for WideCharToMultiByte and you should be sorted
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 14th, 2002, 03:11 PM
#3
Thread Starter
Frenzied Member
Originally posted by parksie
You can use this raw under 2000
Ok, I am in 2000, so how do I do this?
-
Jun 14th, 2002, 03:35 PM
#4
Monday Morning Lunatic
What are you using? Is it a console app?
I think you can just output it to wcout in the usual manner. It's hazy trying to use both in one program, though - either convert everything to Unicode, or everything to the multibyte set (the normal char* stuff...yes I know it's called multibyte but for most characters 1 byte will suffice).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 14th, 2002, 04:04 PM
#5
Thread Starter
Frenzied Member
It is in console for now.
To be honest with you, I am in a bit of a mess. I am trying to enumerate the Protected Storage in W2K like here http://www.codeproject.com/w2k/pseenuma.asp
Here is the code I have so far.
Code:
#include <windows.h>
#include <iostream>
using namespace std;
// import type library.
#import <pstorec.dll> no_namespace
// function pointer
typedef HRESULT (WINAPI *PStoreCreateInstancePtr)(IPStore **, DWORD, DWORD, DWORD);
void main(){
CoInitialize(NULL);
HMODULE hPstoreDLL;
hPstoreDLL = LoadLibrary("pstorec.dll");
PStoreCreateInstancePtr PStoreCreateInstance;
PStoreCreateInstance =
(PStoreCreateInstancePtr)GetProcAddress(hPstoreDLL, "PStoreCreateInstance");
IPStorePtr spPStore;
HRESULT hRes;
hRes = PStoreCreateInstance(&spPStore, 0, 0, 0);
IEnumPStoreTypesPtr spEnumTypes;
hRes = spPStore->EnumTypes(0, 0, &spEnumTypes);
GUID typeGUID;
unsigned long ul1;
for(int i = 0; i < 5; i++) // Internet Explorer Type
hRes = spEnumTypes->Next(1, &typeGUID, &ul1);
IEnumPStoreTypesPtr spEnumSubTypes;
GUID subtypeGUID;
hRes = spPStore->EnumSubtypes(0, &typeGUID, 0, &spEnumSubTypes);
hRes = spEnumSubTypes->Next(0, &subtypeGUID, &ul1); // Internet Explorer Subtype
IEnumPStoreItemsPtr spEnumItems;
hRes = spPStore->EnumItems(0, &typeGUID, &subtypeGUID, 0, &spEnumItems);
LPWSTR lpwstr;
hRes = spEnumItems->Next(0, &lpwstr, &ul1);
wcout << lpwstr << endl;
CoUninitialize();
}
... and you see what happens.
-
Jun 14th, 2002, 04:06 PM
#6
Thread Starter
Frenzied Member
PS - Anybody that knows win2K Protected Storage, feel free to jump in.
-
Jun 14th, 2002, 04:09 PM
#7
Monday Morning Lunatic
Code:
hRes = spEnumItems->Next(0, &lpwstr, &ul1);
Shouldn't that just be "lpwstr" not "&lpwstr"?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 15th, 2002, 03:02 AM
#8
Thread Starter
Frenzied Member
Well, one would think it should be. The parameter is actually
LPWSTR* rgelt
go figure.
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
|