|
Thanks for the reply.
Henry miller wrote:
Instead of poping up the list, parse it looking for your device.
I don't have a list of devices, that is what I need and then to be able to select one automatically for the user.
What happens at the moment is that the command 'CreateFile' (which opens the comm port) calls a window/program called 'Bluetooth Console' and I manually select the device from there, then it continues to run my application.
I thought perhaps the registry might contain a list of available devices. I've never done anything with the registry so perhaps I am barking up the wrong tree.
Ali
|
|
|
|
|
go to MSDN and lookup setupapi in particular things like SetupDiGetClassDevs. Once you get close there are a lot of functions to lookup and understand - start reading.
I know our code uses those functions somehow to get a list of devices (CD drives in our case), but it is complex, and under several layers of wrappers that I'm not about to unwind if I don't have to. Good luck figuring it out.
|
|
|
|
|
Thanks, I'll go take a look.
I've been 'Googling' for some help with this but I didn't have a starting point and so my searches have been pretty fruitless.
Henry miller wrote:
Once you get close there are a lot of functions to lookup and understand - start reading.
Its sounds like it will take a while so I better stop typing and get on with it!
Cheers,
Ali
|
|
|
|
|
Well,I look into limits.h and see that "short" consists of 2 bytes on my machine and there are 4 bytes for "int" type. So,
1) what does it depend on? (OS, compiler, CPU)
2) Suppose I use such a variable in my prog:
short a;
a=32000;
and than run it on the machine where "short" consists of 1 byte. Will it work correctly?
|
|
|
|
|
1) From my understanding, the size of the variable depends on the compiler and/or OS (whether 16bit-, 32bit-, or 64bit-based I think).
2) If you ever ran into a situation where a short took only a byte, you wouldn't be able to get a to 32000 . The highest number you could get to would be 255 . Look below at the binary math:
1111 1111
1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 = 255
I doubt though that you will ever run into a situation where a short will only take a byte of memory. I hope that this helps.
Happy Programming and God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
NO! The maximum number you can get in 8 bits is 255
1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 !!!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Being pedantic, INT is a signed value.
For an 8-bit value, the range is 0000 0000 to 1111 1111.
BUT . . . 0000 0001 to 0111 1111 are positive, while for 1000 0000 to 1111 1111, the sign bit (MSb) is 1, so these are negative numbers.
The range is thus -128 to +127 for a 1-byte INT.
10 or 15 years ago, I did some development on Windows 3.11 using Turbo C++ 3.1 (16-bit Integers.) I carefully used only ANSI C commands, for portability, but I also used INTs, instead of SHORT & LONG. This really caused problems when I ported the code to a MicroVax running VMS (32-bit INT, as I recall.)
|
|
|
|
|
NormanS wrote:
Being pedantic, INT is a signed value.
Quite, though I was pointing out the mistake in binary mathematics. Still my statement stands as I do not metion type
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Kamis wrote:
what does it depend on
The ANSI standards do not impose any restrictions on the size of short, int or long data types, and for portable code, you should make no assumptions. Famously, some (many) years ago, the Microsoft C++ compiler changed the size of an int from 2 bytes to 4 bytes, and broke all sorts of code (including a lot of internal MS stuff), that had hard-coded the assumption that sizeof(int) was 2.
In the Windows world, if you need a guaranteed size, you can use BYTE , WORD and DWORD data types.
If you need code to be portable, you have to make use of sizeof() and all of the #define s in limits.h and/or other header files.
|
|
|
|
|
|
Once upon a time, in a land not so very far from here there was a machine. This machine seems just like any other computer at first glance, but when you look closer you discover the size of short, int, and long are all 36 bits!
Don't make any assumptions lest you one day be called upon to port you code to that machine.
You can of course decide how far to go. If your program is using MFC you can be confident that porting to non-windows won't happen, so you only need to consider windows. Microsoft is unlikely to make short less than 16 bits, but it might be bigger.
In general it is safe to assume that short is 16 bits because any machine where that is not the case will either have more bits, or other serious limitations that you have to take into account from the start of design. (they still make 4 bit CPUs, but the code that runs on them is all written in house)
More important these days is to note that sizeof(int) is no longer == sizeof(VOID *). This is breaking a lot of code, 64 bit CPUs are here today some people even have them on their desktop without knowing it. (though windows doesn't use all 64 bits yet, that will come)
|
|
|
|
|
You can use GDI and GDI+ in the same application. You can continue to use the GetFontUnicodeRanges API. You can call Graphics::GetHDC to get a GDI HDC from a GDI+ Graphics object. Call Graphics::ReleaseHDC to unlock it when you're finished.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thank you very match, but i want to avoid a duplucate Windows object HFONT (once as member of GDI+ Font class, and secong HFONT, that i need to select (SelectObject) into HDC for forwarding HDC to GetFontUnicodeRanges):
<br />
Status st=Ok;<br />
INT nFound=0;<br />
InstalledFontCollection InstalledFonts;<br />
INT nCount=InstalledFonts.GetFamilyCount();<br />
FontFamily *pInstalledFamilyes=new FontFamily[nCount];<br />
st=InstalledFonts.GetFamilies(nCount,pInstalledFamilyes,&nFound);<br />
ATLASSERT(st==Ok);<br />
<br />
for(INT i=0;i<nFound;i++)<br />
{<br />
BOOL bFontFound=FALSE;<br />
Font FoundFont(&pInstalledFamilyesi],fontSize,FontStyleRegular,UnitPixel);
if(FoundFont.GetLastStatus()!=Ok)<br />
continue;<br />
LOGFONTW lf;<br />
FoundFont.GetLogFontW(pGr,&lf);<br />
HFONT hFont=::CreateFontIndirect(&lf);
ATLASSERT(hFont);<br />
<br />
WTL::CDC dc;
dc.CreateCompatibleDC(pGr->GetHDC());<br />
<br />
<br />
HFONT hOldFont=(HFONT)::SelectObject(dc,hFont);<br />
<br />
GLYPHSET *pGlSet=NULL;<br />
DWORD nSize=::GetFontUnicodeRanges(dc,pGlSet);
if(nSize==0)<br />
continue;<br />
pGlSet=new GLYPHSET[nSize];<br />
::GetFontUnicodeRanges(dc,pGlSet);
<br />
pGr->ReleaseHDC(dc);<br />
So can i to avoid duplicate creation of the tested font.
Thanks.
|
|
|
|
|
I can do the following with 'int' with ease:
1: get the address of the pointer
2: get the contents of the pointer (the address it points too)
3: get the value of the variable pointed too.
int *a;
int b = 'B';
cout <<"address of b (the var) = " <<&b <
|
|
|
|
|
Modify the code as follows.
It should serv your purpose.
void main(){
char *a;
char b = 'B';
a = &b;
cout <<"address of a = " <<&a <
|
|
|
|
|
Can you please explain this to me:
(unsigned long)(*(&a))
thanks
|
|
|
|
|
a contains address of b. But if you say cout << a, it won't print the contents of a ( i.e address of b).
But you know it is address i.e. unsigned long type, so force it to print conent of a as an address.
Actually referencing & derefrerncing in the statment is not required.
i.e (unsigned long)(*(&a)) is same as (unsigned long)(a)
|
|
|
|
|
hmmm, yes that makes much more sense, thanks!
|
|
|
|
|
I`m having problem on getting list of tables from ODBC data source. I use SQLTable, but it didn`t work. It think it`s the first parameter. does anybody knows what to pass to the first parameter( h_stmt)? Thank you. I hope this is a good question.
|
|
|
|
|
The first parameter is a SQLHSTMT variable.
SQLHSTMT h_stmt;
I am unaware of any SQLTables examples BUT If you look at the example for SQLColumns[^] does that help?
If not can you post a snippet of the code you are trying to use.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
See here.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I tried looking through a few of the articles that were given on the site about using the clipboard, but none of them really made sense to me or helped.
I am trying to make the following call:
frame1 = Clipboard.GetDataObject();
But I keep getting the following error:
error C2065: 'Clipboard' : undeclared identifier
Now I assumed that I had to add an include directive to fix this problem, however, after much searching through the MSDN I wasn't able to come up with anything. Any help with this problem would be very much appreciated.
Micheal
|
|
|
|
|
tunerica wrote:
frame1 = Clipboard.GetDataObject();
Sounds like VB no?
Are you sure this[^] didnt help?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I'm using Visual C++, have I set it up as if I was using VB?
I did look at that article but couldn't really get anything from it.
To explain further what I am trying to do, I have used the function capEditCopy to put a frame from the video buffer to the clipboard. I wanted to assign that data to frame1 which is an IDataObject. If anyone knows a better way to do it, I would be happy to give it a try. But if you tell me what my error is that would be even better.
Micheal
|
|
|
|
|
OleGetClipboard( &frame1 );
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|