find text into parameter BSTR type

Hi. How to find id text "123" (this parameter is a id product) into parameter "Sxs@123@aa". This parameters is BSTR.

Thankss..
You can use wcsstr. It's the wide version of strstr.
http://msdn.microsoft.com/en-us/library/z9da80kz%28VS.80%29.aspx
Thanks kbw, but wcsstr is to static text,no? .Can i show me a littel sample code,please??. Thanks,thanks and thanks for your help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <windows.h>
#include <iostream>
#include <string.h>

int main()
{
	BSTR source_text = L"Sxs@123@aa";
	BSTR search_text = L"123";

	BSTR result = wcsstr(source_text, search_text);
	if (result)
		std::cout << "Found match" << std::endl;
	else
		std::cout << "No match found" << std::endl;

	return 0;
}
Thanks for your reply. But muy problem is than souce_text not is static, is dynamic parameter. Example:

BSTR found(BST code_id) // scd@123@s or xsd@4562222@d ,...
{

BSTR source_text = (code_id); --->first my problem
BSTR search_text = L"@";

//1-. find first of
start = find_first_of.....
.....
//2-. find las of
end = find_last_of....
...
//3-. substring (source_text,start,end)

//4-. And use this substring for a select.
}

Can i help me for this big big problem??

Thanks, very thanks.
I don't really understand what the problem is. Are you saying the strings are parameterised?

I don't know if this code helps, if it doesn't, then I have no idea what the problem is. I've not compiled this so it may have errors.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <windows.h>
#include <iostream>
#include <string.h>

BSTR find(BSTR source, BSTR search)
{
    return wcsstr(source, search);
}

int main()
{
    BSTR str = find(L"Sxs@123@aa", L"123");
    if (str)
        std::cout << "found" << std::endl;
    else
        std::cout << "not found" << std::endl;
}
Sorry! I wasn't able to express myself very well!

The question is:

I have a function which the enter parameter type is BSTR. For example: Sxs@123@aa.

1) I would like to know how I can get "123" when "123" is a non static text, it is a code ID.

2) Once I get or find this code ID, how can I return this code ID to a BSTR or _bstr_t?

Please, can somebody help me with this question? And can somebody send me an example?
Last edited on
Topic archived. No new replies allowed.