Skip to main content
GameDev.net gamedev.net
🔒 Locked

BSTR question

Started by atlnewbie Oct 18, 2001 at 10:15 AM 1 replies 400+ views
Original Post
atlnewbie
atlnewbie
How come the following gives me an access violation? BSTR *s = NULL; *s = SysAllocString(L"string");
IaM
IaM
Because the variable s points to NULL, and the line

*s = SysAllocString(L"string");

makes the result of SysAllocString() to be stored in the memory position stored in s, and because that position is NULL, it gives you an access violation.

Try doing this:

s = SysAllocString(L"string");

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.