|
hi
CString str = "000001";
unsigned short st =_com_util::ConvertStringToBSTR(str);
st = 0x00000 is coming...
please help any body..
|
|
|
|
|
If you dont bother to get the value in unsigned long then strtoul, wcstoul can be used[^].
Member 3653751 wrote: unsigned short st =_com_util::ConvertStringToBSTR(str);
Well your code is not seems to be correct. It convert the LPTSTR to BSTR, it wont convert it to unsigned short
Величие не Бога может быть недооценена.
|
|
|
|
|
hi
convertStringtoBSTR() this function is returning unsigned short only...
i am giving correct input....but output is coming worning....
please help....
actual my problem is i have vb dll...
Public Function f1(SendString As String) As String
after loading vb dll
t is the class pointer of vb dll...
CString str = "000001";
unsigned short *stemp = _com_util::ConvertStringToBSTR(str); //stemp = 48 means 0
t->f1(&stemp) input / output unsigned short its showing...
|
|
|
|
|
You also need to read the documentation for ConvertStringToBSTR() .
[edit]Also you need to understand C programming and return values.[/edit]
It's time for a new signature.
|
|
|
|
|
We already explained how to do this here[^]. Please take some time to read the documentation in the posted link.
It's time for a new signature.
|
|
|
|
|
Hiii...
During an interview I got a question like this
A class looks like:
Class A{
private: int x,y;
public: getxy(int &,int &);
setxy(int x,inty)
}
In above class functions outside the class can't access x and y, how you will do this in C language ( i.e., that is data encapsulation in C)
Actually I couldn't answer this question. I think data encapsulation is possible in C, but if I say "yes" as answer then interviewer will ask how.So struggled to give an answer.
Later I read somewhere data encapsulation is possible in C , and somewhere is specified that it is not possible, is only possible with oops languages....
Anyway anybody can give a good clarification....It will be useful for all
Thanking you
Krish
|
|
|
|
|
As I know,
there are no "out-/inside" words in C
virtual void BeHappy() = 0;
|
|
|
|
|
Encapsulation is definitely my favourite feature of object oriented programming. In plain old C you have structs and unions to group variables together, though the access rights are limited. You can use "internal data structures" by not exposing them outside your module, for example by declaring them static in a C source file. With a little bit of organisation you can have "inner/outer" variables.
So instead of the complier enforcing these access rights, the developer has to do it in C. It's really not much more than that, for example take a C++ class with private members and compile it into an object file or library. Then make a copy of the header file, change private to public... voila you can access all previously private members and the compiler/linker won't complain. Evil but possible.
Hope it helps!
/M
|
|
|
|
|
I guess this[^] is what you are talking about. Hope the link helps the OP.
|
|
|
|
|
I found a article, with the help of example specifying how we can encapsulate the abstract types in C
Just have a look with that [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
|
That! The idiom is sometimes called "Pimpl" (pointer to implementation).
|
|
|
|
|
I used to do this in C all time by leveraging how files and the keyword "static" are used. Like many before me, in some ways, I invented a this pointer without realizing it!
And here's the thing: sometimes I even do something similar with C++, though it can usually be slightly more elegant. Most recently, I did something similar with a Win32 DLL that had a straight C interface (so it could be called from .NET.)
|
|
|
|
|
I use the software "Everest" to obtain detailed infomation about my cdroms,
including description,serial number ,cach size and so on .
Now I wonder how "Everest" obtain such detailed infomation.
Now I just need the serial number of my cdrom. How? Thanks.
|
|
|
|
|
What about GetVolumeInformation[^] function?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have tested GetVolumeInformation(), it can only obtain the physical disk C:\ .. but it can not do with my H:\ (my cdrom)
|
|
|
|
|
You can use Win32_CDROMDrive WMI class for retrieving all the information about CD ROM drive. Check out the MSDN page[^]
|
|
|
|
|
yes, I just used Win32_CDROMDrive .
But the member VolumeSerialNumber is empty ,
and
SerialNumber
Data type: uint16
Access type: Read-only
Number supplied by the manufacturer that identifies the physical media. Example: WD-WM3493798728.
Windows Server 2003, Windows XP, Windows 2000, Windows NT 4.0, and Windows Me/98/95: This property is not available.
I am on Windows XP.
Thanks
|
|
|
|
|
You can try using Win32_PhysicalMedia WMI class.
According to MSDN[^] it supports XP. Also there is no restriction documented on the OS for retrieving Serial number using Win32_PhysicalMedia.
|
|
|
|
|
I tried Win32_PhysicalMedia , I do not know why I only got \\.\PHYSICALDRIVE0 ,
and almost all of the detailed infomation is NULL(such as "Name").
while I could get detailed infomation with Win32_CDROMDrive.
Thanks anyway
|
|
|
|
|
You'll need to issue IOCTL_READ_TOC_EXT[^], with parameter CDROM_READ_TOC_EX_FORMAT_CDTEXT. Your serial number will then be in CDROM_CD_TEXT_PACK_DISC_ID, or CDROM_CD_TEXT_PACK_UPC_EAN, can't remember which one . Note that this is for commercial music cds. (and it doesn't work for all).
There is also a bar code encoded in the innermost ring of CD's and DVD (flip one over, and take a close look at the inner ring, you'll see a huge barcode). This one is returned by http://msdn.microsoft.com/en-us/library/aa394346(VS.85).aspx[^] Serial Number (this works even for R/W devices, and it's how windows differentiates between CDs or DVDS used for writing.
So you'll have to decide which one you want. The first one is mostly used for commercial cdroms, and is encoded in the subtext layer on recent cdroms. You'll need a drive that can read subtext, most of them do nowadays.
The other one exists on all cd's/DVD's, again the drive must be capable of reading it. Recent ones all do.
modified on Monday, April 26, 2010 6:05 AM
|
|
|
|
|
Nice !
I will test it !
Thanks a lot!
|
|
|
|
|
How to write Selp Extractor programatically without using any third party tool using vc++.
|
|
|
|
|
Coding.
You need to write an executable that expands the previous compressed, data embedded in the executable itsef (so, I guess, you have to write the code implementing a compression/decompression algorithm).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
windows doesnt provide any API for this?
|
|
|
|