dev-cpp-users Mailing List for Dev-C++ (Page 39)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Per W. <pw...@ia...> - 2007-12-22 18:57:28
|
Too little information given! If the image is in any known image format (GIF, JPEG, TIFF, PCX, BMP, ...) then you need to locate a graphics library that contains code to read that format. If the data is in a raw binary file or stored as ASCII, then you have to write your own code. There is no way anyone can help you, if you don't take your time and clearly specify your problem! /pwm On Sat, 22 Dec 2007, Benson Mwangi wrote: > Hello Everyone, > > Is anyone aware of how to read a greyscale image and convert it into a 2D > array of 256 by 256 in C++. > > I would appreciate your contribution on this. > > Kind regards > Benson. > |
From: Benson M. <ben...@gm...> - 2007-12-22 18:03:53
|
Hello Everyone, Is anyone aware of how to read a greyscale image and convert it into a 2D array of 256 by 256 in C++. I would appreciate your contribution on this. Kind regards Benson. |
From: Per W. <pw...@ia...> - 2007-12-20 15:19:11
|
Yes, strdup() is a nice function to know. If doing the allocation on program startup, you can normally ignore to release the memory. If doing it in a loop or not needing the results when your function ends, then you should do free() on all pointers returned from strdup(). Try to google for "man strdup". /pwm On Thu, 20 Dec 2007, Jessica Chen wrote: > yep.. i will change 4096*256=1M part. that is too big for saving serial > port info. > > the function of strdup is equal to strlen() + malloc() + memcpy()? > so, i don't need to do memalloc for strSerialList as what i did, since > strdup() will do? > is this a correct understanding? > > > > On Dec 20, 2007 9:23 AM, Per Westermark <pw...@ia...> wrote: > > > Now, you are preallocating 4096 bytes for 256 serial ports. That is 1MB of > > memory. That is not something you want in production code. > > > > My change with strdup() would have performed a strlen() + an optimum-sized > > malloc() + memcpy() for any detected serial ports, i.e. it will end up > > needing at the most a couple of hundred bytes of memory for the names. > > > > /pwm > > > > On Thu, 20 Dec 2007, Jessica Chen wrote: > > > > > Hi, Per, > > > > > > Thanks. I asked my friend to see. He gave me the suggestion. The > > > RegEnumValue can recognize the com and USB->COM. The problem solved > > now, I > > > got the correct result: COM1(com), COM7(usb->com). In front of > > > RegEnumValue, add: > > > dwName = sizeof(Name); > > > dwSizeofPortName = sizeof(szPortName); > > > So the whole code is as follows (a bug in it: didn't release memalloc, > > but > > > doesn't influence the result here). > > > > > > #include <windows.h> > > > #include <stdio.h> > > > #include <tchar.h> > > > > > > int main(void) > > > { > > > int z; > > > char *strSerialList[256]; > > > for (z=0; z<=256; z++) > > > { > > > strSerialList[z] = (char*)malloc(4096*sizeof(char)); > > > } > > > HKEY hKey; > > > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > > 0, > > > KEY_READ, > > > &hKey) != ERROR_SUCCESS) > > > { > > > return -1; > > > } > > > > > > int i=0; > > > CHAR Name[4096]; > > > UCHAR szPortName[4096]; > > > LONG Status; > > > DWORD dwIndex = 0; > > > DWORD dwName; > > > DWORD dwSizeofPortName; > > > DWORD Type; > > > dwName = sizeof(Name); > > > dwSizeofPortName = sizeof(szPortName); > > > > > > do > > > { > > > dwName = sizeof(Name); > > > dwSizeofPortName = sizeof(szPortName); > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > > &Type, > > > szPortName, &dwSizeofPortName); > > > printf("Name=%s,szPortName=%s \n", Name, szPortName); > > > if((Status == ERROR_SUCCESS) ) > > > { > > > strcpy(strSerialList[i],(char*)szPortName); > > > //strSerialList[i] = (char*) szPortName; > > > printf("%s ",strSerialList[i]); > > > printf("i=%d,dwIndex=%d\n",i,dwIndex); > > > i++; > > > } > > > } while((Status == ERROR_SUCCESS) ); > > > RegCloseKey(hKey); > > > > > > printf("\n\n"); > > > for(int j=0;j<i;j++) > > > { > > > printf("%s\n",strSerialList[j]); > > > } > > > > > > return 0; > > > } > > > > > > > > > > > > On Dec 19, 2007 6:02 PM, Per Westermark <pw...@ia...> wrote: > > > > > > > On an old test machine I have, the original code produces: > > > > COM1 > > > > COM1 > > > > COM1 > > > > COM1 > > > > COM1 > > > > COM1 > > > > > > > > After adding strdup(), I get: > > > > COM5 > > > > COM6 > > > > COM7 > > > > COM7 > > > > COM4 > > > > COM1 > > > > > > > > Are you sure that your change was correct, and that you remembered to > > > > recompile? > > > > > > > > One interesting thing here is that COM7 is printed twice, while my > > much > > > > used COM3 is not enumerated. > > > > > > > > The two COM7 seems to be a stupid M$ bug with an USB serial adapter :( > > > > > > > > /pwm > > > > > > > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > > > > > > > Hi, Per, > > > > > > > > > > for your second method, i modified like this. i doesn't solve the > > > > > problem. the result is the same as before. > > > > > for the first method, i tried to change strSerialList[i] = > > > > > (char*)(szPortName); to strSerialList[i] = > > strdup((char*)(szPortName));, > > > > but > > > > > it seems doesn't work too. :-( > > > > > > > > > > Regards, > > > > > Jessica > > > > > > > > > > do > > > > > { > > > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > > > > &Type, > > > > > szPortName, &dwSizeofPortName); > > > > > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > > > > > { > > > > > strSerialList[i] = (char*)(szPortName); > > > > > printf("%s\n",strSerialList[i]); > > > > > i++; > > > > > } > > > > > } while((Status == ERROR_SUCCESS) || (Status == > > ERROR_MORE_DATA)); > > > > > RegCloseKey(hKey); > > > > > > > > > > On Dec 19, 2007 2:44 PM, Per Westermark <pw...@ia...> > > wrote: > > > > > > > > > > > The test code is buggy. It uses the same buffer to retrieve the > > device > > > > > > names, which means that the name will be overwritten. > > > > > > > > > > > > A quicky (with a memory leak that doesn't matter here) is to do > > > > > > strSerialList[i] = strdup((char*)szPortName); > > > > > > > > > > > > Another alternative is to print the devices one-by-one directly > > when > > > > they > > > > > > are found. > > > > > > > > > > > > /pwm > > > > > > > > > > > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > > > > > > > > > > > Name Type Data > > > > > > > (Default) REG_SZ (value not set) > > > > > > > \Device\Serial0 REG_SZ COM1 > > > > > > > \Device\U2SPORT1 REG_SZ COM7 > > > > > > > > > > > > > > if i used on my computer, i can see: > > > > > > > COM1 > > > > > > > COM1 > > > > > > > > > > > i> > > when i used my .exe on my colleagues computer. > > > > > > > he has 2 serial port and 1 usb->serial. > > > > > > > but we can only see "COM4" for 3 times. > > > > > > > > > > > > > > so at least, the code can recognize how many COM on computer, > > > > whatever > > > > > > real > > > > > > > com port or usb-com. > > > > > > > but cannot read right com port number. > > > > > > > > > > > > > > > > > > > > > On Dec 19, 2007 1:57 PM, Rafael Menezes <so...@gm...> > > wrote: > > > > > > > > > > > > > > > Hi Jessica. > > > > > > > > > > > > > > > > Can you, for start, list what is on > > > > "HARDWARE\\DEVICEMAP\\SERIALCOMM" > > > > > > in > > > > > > > > your computer? > > > > > > > > > > > > > > > > Regards > > > > > > > > Rafael > > > > > > > > > > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > > > > > > > > > > > > > > > Hi, thanks for ur email, Rafael. > > > > > > > > > > > > > > > > > > I researched myself. > > > > > > > > > I wrote a code. I will list it as follows. > > > > > > > > > The problem seems it can recognize the real serial com port > > (Com > > > > 1 > > > > > > in my > > > > > > > > > computer, registry). > > > > > > > > > But on my computer, I have a USB->serial com port (Com 7 in > > my > > > > > > > > > computer, registry). > > > > > > > > > The code cannot recognize the USB->serial com port. > > > > > > > > > Is there any experienced persons can give any idea about > > that? > > > > > > > > > > > > > > > > > > #include <windows.h> > > > > > > > > > #include <stdio.h> > > > > > > > > > #include <tchar.h> > > > > > > > > > > > > > > > > > > int main(void) > > > > > > > > > { > > > > > > > > > char *strSerialList[256]; > > > > > > > > > HKEY hKey; > > > > > > > > > > > > > > > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > > > > > > > > > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > > > > > > > > 0, > > > > > > > > > KEY_READ, > > > > > > > > > &hKey) != ERROR_SUCCESS) > > > > > > > > > { > > > > > > > > > return -1; > > > > > > > > > } > > > > > > > > > > > > > > > > > > int i=0; > > > > > > > > > CHAR Name[25]; > > > > > > > > > UCHAR szPortName[25]; > > > > > > > > > LONG Status; > > > > > > > > > DWORD dwIndex = 0; > > > > > > > > > DWORD dwName; > > > > > > > > > DWORD dwSizeofPortName; > > > > > > > > > DWORD Type; > > > > > > > > > dwName = sizeof(Name); > > > > > > > > > dwSizeofPortName = sizeof(szPortName); > > > > > > > > > > > > > > > > > > do > > > > > > > > > { > > > > > > > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, > > > > NULL, > > > > > > > > > &Type, > > > > > > > > > szPortName, &dwSizeofPortName); > > > > > > > > > if((Status == ERROR_SUCCESS) || (Status == > > > > ERROR_MORE_DATA)) > > > > > > > > > { > > > > > > > > > strSerialList[i] = (char*)(szPortName); > > > > > > > > > i++; > > > > > > > > > } > > > > > > > > > } while((Status == ERROR_SUCCESS) || (Status == > > > > > > ERROR_MORE_DATA)); > > > > > > > > > RegCloseKey(hKey); > > > > > > > > > > > > > > > > > > for(int j=0;j<i;j++) > > > > > > > > > { > > > > > > > > > printf("%s\n",strSerialList[j]); > > > > > > > > > } > > > > > > > > > > > > > > > > > > return 0; > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> > > > > wrote: > > > > > > > > > > > > > > > > > > > You can send mails. Can you search on google? > > > > > > > > > > > > > > > > > > > > > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta = > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > > > > > > > > > = > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm... > > > wrote: > > > > > > > > > > > > > > > > > > > > > is there anyone have the experience for writing code of > > > > getting > > > > > > the > > > > > > > > > > > serial port info from windows? > > > > > > > > > > > can u give me an sample code? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > SF.Net email is sponsored by: > > > > > > > > > > > Check out the new SourceForge.net Marketplace. > > > > > > > > > > > It's the best place to buy or sell services > > > > > > > > > > > for just about anything Open Source. > > > > > > > > > > > > > > > > > > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > Dev-cpp-users mailing list > > > > > > > > > > > Dev...@li... > > > > > > > > > > > TO UNSUBSCRIBE: > > > > http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > > Regards > > > > > > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > Regards > > > > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
From: Jessica C. <jes...@gm...> - 2007-12-20 15:02:39
|
yep.. i will change 4096*256=1M part. that is too big for saving serial port info. the function of strdup is equal to strlen() + malloc() + memcpy()? so, i don't need to do memalloc for strSerialList as what i did, since strdup() will do? is this a correct understanding? On Dec 20, 2007 9:23 AM, Per Westermark <pw...@ia...> wrote: > Now, you are preallocating 4096 bytes for 256 serial ports. That is 1MB of > memory. That is not something you want in production code. > > My change with strdup() would have performed a strlen() + an optimum-sized > malloc() + memcpy() for any detected serial ports, i.e. it will end up > needing at the most a couple of hundred bytes of memory for the names. > > /pwm > > On Thu, 20 Dec 2007, Jessica Chen wrote: > > > Hi, Per, > > > > Thanks. I asked my friend to see. He gave me the suggestion. The > > RegEnumValue can recognize the com and USB->COM. The problem solved > now, I > > got the correct result: COM1(com), COM7(usb->com). In front of > > RegEnumValue, add: > > dwName = sizeof(Name); > > dwSizeofPortName = sizeof(szPortName); > > So the whole code is as follows (a bug in it: didn't release memalloc, > but > > doesn't influence the result here). > > > > #include <windows.h> > > #include <stdio.h> > > #include <tchar.h> > > > > int main(void) > > { > > int z; > > char *strSerialList[256]; > > for (z=0; z<=256; z++) > > { > > strSerialList[z] = (char*)malloc(4096*sizeof(char)); > > } > > HKEY hKey; > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > 0, > > KEY_READ, > > &hKey) != ERROR_SUCCESS) > > { > > return -1; > > } > > > > int i=0; > > CHAR Name[4096]; > > UCHAR szPortName[4096]; > > LONG Status; > > DWORD dwIndex = 0; > > DWORD dwName; > > DWORD dwSizeofPortName; > > DWORD Type; > > dwName = sizeof(Name); > > dwSizeofPortName = sizeof(szPortName); > > > > do > > { > > dwName = sizeof(Name); > > dwSizeofPortName = sizeof(szPortName); > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > &Type, > > szPortName, &dwSizeofPortName); > > printf("Name=%s,szPortName=%s \n", Name, szPortName); > > if((Status == ERROR_SUCCESS) ) > > { > > strcpy(strSerialList[i],(char*)szPortName); > > //strSerialList[i] = (char*) szPortName; > > printf("%s ",strSerialList[i]); > > printf("i=%d,dwIndex=%d\n",i,dwIndex); > > i++; > > } > > } while((Status == ERROR_SUCCESS) ); > > RegCloseKey(hKey); > > > > printf("\n\n"); > > for(int j=0;j<i;j++) > > { > > printf("%s\n",strSerialList[j]); > > } > > > > return 0; > > } > > > > > > > > On Dec 19, 2007 6:02 PM, Per Westermark <pw...@ia...> wrote: > > > > > On an old test machine I have, the original code produces: > > > COM1 > > > COM1 > > > COM1 > > > COM1 > > > COM1 > > > COM1 > > > > > > After adding strdup(), I get: > > > COM5 > > > COM6 > > > COM7 > > > COM7 > > > COM4 > > > COM1 > > > > > > Are you sure that your change was correct, and that you remembered to > > > recompile? > > > > > > One interesting thing here is that COM7 is printed twice, while my > much > > > used COM3 is not enumerated. > > > > > > The two COM7 seems to be a stupid M$ bug with an USB serial adapter :( > > > > > > /pwm > > > > > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > > > > > Hi, Per, > > > > > > > > for your second method, i modified like this. i doesn't solve the > > > > problem. the result is the same as before. > > > > for the first method, i tried to change strSerialList[i] = > > > > (char*)(szPortName); to strSerialList[i] = > strdup((char*)(szPortName));, > > > but > > > > it seems doesn't work too. :-( > > > > > > > > Regards, > > > > Jessica > > > > > > > > do > > > > { > > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > > > &Type, > > > > szPortName, &dwSizeofPortName); > > > > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > > > > { > > > > strSerialList[i] = (char*)(szPortName); > > > > printf("%s\n",strSerialList[i]); > > > > i++; > > > > } > > > > } while((Status == ERROR_SUCCESS) || (Status == > ERROR_MORE_DATA)); > > > > RegCloseKey(hKey); > > > > > > > > On Dec 19, 2007 2:44 PM, Per Westermark <pw...@ia...> > wrote: > > > > > > > > > The test code is buggy. It uses the same buffer to retrieve the > device > > > > > names, which means that the name will be overwritten. > > > > > > > > > > A quicky (with a memory leak that doesn't matter here) is to do > > > > > strSerialList[i] = strdup((char*)szPortName); > > > > > > > > > > Another alternative is to print the devices one-by-one directly > when > > > they > > > > > are found. > > > > > > > > > > /pwm > > > > > > > > > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > > > > > > > > > Name Type Data > > > > > > (Default) REG_SZ (value not set) > > > > > > \Device\Serial0 REG_SZ COM1 > > > > > > \Device\U2SPORT1 REG_SZ COM7 > > > > > > > > > > > > if i used on my computer, i can see: > > > > > > COM1 > > > > > > COM1 > > > > > > > > > i> > > when i used my .exe on my colleagues computer. > > > > > > he has 2 serial port and 1 usb->serial. > > > > > > but we can only see "COM4" for 3 times. > > > > > > > > > > > > so at least, the code can recognize how many COM on computer, > > > whatever > > > > > real > > > > > > com port or usb-com. > > > > > > but cannot read right com port number. > > > > > > > > > > > > > > > > > > On Dec 19, 2007 1:57 PM, Rafael Menezes <so...@gm...> > wrote: > > > > > > > > > > > > > Hi Jessica. > > > > > > > > > > > > > > Can you, for start, list what is on > > > "HARDWARE\\DEVICEMAP\\SERIALCOMM" > > > > > in > > > > > > > your computer? > > > > > > > > > > > > > > Regards > > > > > > > Rafael > > > > > > > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > > > > > > > > > > > > > Hi, thanks for ur email, Rafael. > > > > > > > > > > > > > > > > I researched myself. > > > > > > > > I wrote a code. I will list it as follows. > > > > > > > > The problem seems it can recognize the real serial com port > (Com > > > 1 > > > > > in my > > > > > > > > computer, registry). > > > > > > > > But on my computer, I have a USB->serial com port (Com 7 in > my > > > > > > > > computer, registry). > > > > > > > > The code cannot recognize the USB->serial com port. > > > > > > > > Is there any experienced persons can give any idea about > that? > > > > > > > > > > > > > > > > #include <windows.h> > > > > > > > > #include <stdio.h> > > > > > > > > #include <tchar.h> > > > > > > > > > > > > > > > > int main(void) > > > > > > > > { > > > > > > > > char *strSerialList[256]; > > > > > > > > HKEY hKey; > > > > > > > > > > > > > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > > > > > > > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > > > > > > > 0, > > > > > > > > KEY_READ, > > > > > > > > &hKey) != ERROR_SUCCESS) > > > > > > > > { > > > > > > > > return -1; > > > > > > > > } > > > > > > > > > > > > > > > > int i=0; > > > > > > > > CHAR Name[25]; > > > > > > > > UCHAR szPortName[25]; > > > > > > > > LONG Status; > > > > > > > > DWORD dwIndex = 0; > > > > > > > > DWORD dwName; > > > > > > > > DWORD dwSizeofPortName; > > > > > > > > DWORD Type; > > > > > > > > dwName = sizeof(Name); > > > > > > > > dwSizeofPortName = sizeof(szPortName); > > > > > > > > > > > > > > > > do > > > > > > > > { > > > > > > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, > > > NULL, > > > > > > > > &Type, > > > > > > > > szPortName, &dwSizeofPortName); > > > > > > > > if((Status == ERROR_SUCCESS) || (Status == > > > ERROR_MORE_DATA)) > > > > > > > > { > > > > > > > > strSerialList[i] = (char*)(szPortName); > > > > > > > > i++; > > > > > > > > } > > > > > > > > } while((Status == ERROR_SUCCESS) || (Status == > > > > > ERROR_MORE_DATA)); > > > > > > > > RegCloseKey(hKey); > > > > > > > > > > > > > > > > for(int j=0;j<i;j++) > > > > > > > > { > > > > > > > > printf("%s\n",strSerialList[j]); > > > > > > > > } > > > > > > > > > > > > > > > > return 0; > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> > > > wrote: > > > > > > > > > > > > > > > > > You can send mails. Can you search on google? > > > > > > > > > > > > > > > > > > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta = > > > > > > > > > > > > > > > > > > > > > > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > > > > > > > > = > > > > > > > > > > > > > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm... > > wrote: > > > > > > > > > > > > > > > > > > > is there anyone have the experience for writing code of > > > getting > > > > > the > > > > > > > > > > serial port info from windows? > > > > > > > > > > can u give me an sample code? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > SF.Net email is sponsored by: > > > > > > > > > > Check out the new SourceForge.net Marketplace. > > > > > > > > > > It's the best place to buy or sell services > > > > > > > > > > for just about anything Open Source. > > > > > > > > > > > > > > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > Dev-cpp-users mailing list > > > > > > > > > > Dev...@li... > > > > > > > > > > TO UNSUBSCRIBE: > > > http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > Regards > > > > > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > Regards > > > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
From: Per W. <pw...@ia...> - 2007-12-20 14:23:57
|
Now, you are preallocating 4096 bytes for 256 serial ports. That is 1MB of memory. That is not something you want in production code. My change with strdup() would have performed a strlen() + an optimum-sized malloc() + memcpy() for any detected serial ports, i.e. it will end up needing at the most a couple of hundred bytes of memory for the names. /pwm On Thu, 20 Dec 2007, Jessica Chen wrote: > Hi, Per, > > Thanks. I asked my friend to see. He gave me the suggestion. The > RegEnumValue can recognize the com and USB->COM. The problem solved now, I > got the correct result: COM1(com), COM7(usb->com). In front of > RegEnumValue, add: > dwName = sizeof(Name); > dwSizeofPortName = sizeof(szPortName); > So the whole code is as follows (a bug in it: didn't release memalloc, but > doesn't influence the result here). > > #include <windows.h> > #include <stdio.h> > #include <tchar.h> > > int main(void) > { > int z; > char *strSerialList[256]; > for (z=0; z<=256; z++) > { > strSerialList[z] = (char*)malloc(4096*sizeof(char)); > } > HKEY hKey; > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > 0, > KEY_READ, > &hKey) != ERROR_SUCCESS) > { > return -1; > } > > int i=0; > CHAR Name[4096]; > UCHAR szPortName[4096]; > LONG Status; > DWORD dwIndex = 0; > DWORD dwName; > DWORD dwSizeofPortName; > DWORD Type; > dwName = sizeof(Name); > dwSizeofPortName = sizeof(szPortName); > > do > { > dwName = sizeof(Name); > dwSizeofPortName = sizeof(szPortName); > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, &Type, > szPortName, &dwSizeofPortName); > printf("Name=%s,szPortName=%s \n", Name, szPortName); > if((Status == ERROR_SUCCESS) ) > { > strcpy(strSerialList[i],(char*)szPortName); > //strSerialList[i] = (char*) szPortName; > printf("%s ",strSerialList[i]); > printf("i=%d,dwIndex=%d\n",i,dwIndex); > i++; > } > } while((Status == ERROR_SUCCESS) ); > RegCloseKey(hKey); > > printf("\n\n"); > for(int j=0;j<i;j++) > { > printf("%s\n",strSerialList[j]); > } > > return 0; > } > > > > On Dec 19, 2007 6:02 PM, Per Westermark <pw...@ia...> wrote: > > > On an old test machine I have, the original code produces: > > COM1 > > COM1 > > COM1 > > COM1 > > COM1 > > COM1 > > > > After adding strdup(), I get: > > COM5 > > COM6 > > COM7 > > COM7 > > COM4 > > COM1 > > > > Are you sure that your change was correct, and that you remembered to > > recompile? > > > > One interesting thing here is that COM7 is printed twice, while my much > > used COM3 is not enumerated. > > > > The two COM7 seems to be a stupid M$ bug with an USB serial adapter :( > > > > /pwm > > > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > > > Hi, Per, > > > > > > for your second method, i modified like this. i doesn't solve the > > > problem. the result is the same as before. > > > for the first method, i tried to change strSerialList[i] = > > > (char*)(szPortName); to strSerialList[i] = strdup((char*)(szPortName));, > > but > > > it seems doesn't work too. :-( > > > > > > Regards, > > > Jessica > > > > > > do > > > { > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > > &Type, > > > szPortName, &dwSizeofPortName); > > > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > > > { > > > strSerialList[i] = (char*)(szPortName); > > > printf("%s\n",strSerialList[i]); > > > i++; > > > } > > > } while((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)); > > > RegCloseKey(hKey); > > > > > > On Dec 19, 2007 2:44 PM, Per Westermark <pw...@ia...> wrote: > > > > > > > The test code is buggy. It uses the same buffer to retrieve the device > > > > names, which means that the name will be overwritten. > > > > > > > > A quicky (with a memory leak that doesn't matter here) is to do > > > > strSerialList[i] = strdup((char*)szPortName); > > > > > > > > Another alternative is to print the devices one-by-one directly when > > they > > > > are found. > > > > > > > > /pwm > > > > > > > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > > > > > > > Name Type Data > > > > > (Default) REG_SZ (value not set) > > > > > \Device\Serial0 REG_SZ COM1 > > > > > \Device\U2SPORT1 REG_SZ COM7 > > > > > > > > > > if i used on my computer, i can see: > > > > > COM1 > > > > > COM1 > > > > > > > i> > > when i used my .exe on my colleagues computer. > > > > > he has 2 serial port and 1 usb->serial. > > > > > but we can only see "COM4" for 3 times. > > > > > > > > > > so at least, the code can recognize how many COM on computer, > > whatever > > > > real > > > > > com port or usb-com. > > > > > but cannot read right com port number. > > > > > > > > > > > > > > > On Dec 19, 2007 1:57 PM, Rafael Menezes <so...@gm...> wrote: > > > > > > > > > > > Hi Jessica. > > > > > > > > > > > > Can you, for start, list what is on > > "HARDWARE\\DEVICEMAP\\SERIALCOMM" > > > > in > > > > > > your computer? > > > > > > > > > > > > Regards > > > > > > Rafael > > > > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > > > > > > > > > > > Hi, thanks for ur email, Rafael. > > > > > > > > > > > > > > I researched myself. > > > > > > > I wrote a code. I will list it as follows. > > > > > > > The problem seems it can recognize the real serial com port (Com > > 1 > > > > in my > > > > > > > computer, registry). > > > > > > > But on my computer, I have a USB->serial com port (Com 7 in my > > > > > > > computer, registry). > > > > > > > The code cannot recognize the USB->serial com port. > > > > > > > Is there any experienced persons can give any idea about that? > > > > > > > > > > > > > > #include <windows.h> > > > > > > > #include <stdio.h> > > > > > > > #include <tchar.h> > > > > > > > > > > > > > > int main(void) > > > > > > > { > > > > > > > char *strSerialList[256]; > > > > > > > HKEY hKey; > > > > > > > > > > > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > > > > > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > > > > > > 0, > > > > > > > KEY_READ, > > > > > > > &hKey) != ERROR_SUCCESS) > > > > > > > { > > > > > > > return -1; > > > > > > > } > > > > > > > > > > > > > > int i=0; > > > > > > > CHAR Name[25]; > > > > > > > UCHAR szPortName[25]; > > > > > > > LONG Status; > > > > > > > DWORD dwIndex = 0; > > > > > > > DWORD dwName; > > > > > > > DWORD dwSizeofPortName; > > > > > > > DWORD Type; > > > > > > > dwName = sizeof(Name); > > > > > > > dwSizeofPortName = sizeof(szPortName); > > > > > > > > > > > > > > do > > > > > > > { > > > > > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, > > NULL, > > > > > > > &Type, > > > > > > > szPortName, &dwSizeofPortName); > > > > > > > if((Status == ERROR_SUCCESS) || (Status == > > ERROR_MORE_DATA)) > > > > > > > { > > > > > > > strSerialList[i] = (char*)(szPortName); > > > > > > > i++; > > > > > > > } > > > > > > > } while((Status == ERROR_SUCCESS) || (Status == > > > > ERROR_MORE_DATA)); > > > > > > > RegCloseKey(hKey); > > > > > > > > > > > > > > for(int j=0;j<i;j++) > > > > > > > { > > > > > > > printf("%s\n",strSerialList[j]); > > > > > > > } > > > > > > > > > > > > > > return 0; > > > > > > > } > > > > > > > > > > > > > > > > > > > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> > > wrote: > > > > > > > > > > > > > > > You can send mails. Can you search on google? > > > > > > > > > > > > > > > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta = > > > > > > > > > > > > > > > > > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > > > > > > > = > > > > > > > > > > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm... > wrote: > > > > > > > > > > > > > > > > > is there anyone have the experience for writing code of > > getting > > > > the > > > > > > > > > serial port info from windows? > > > > > > > > > can u give me an sample code? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > SF.Net email is sponsored by: > > > > > > > > > Check out the new SourceForge.net Marketplace. > > > > > > > > > It's the best place to buy or sell services > > > > > > > > > for just about anything Open Source. > > > > > > > > > > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > Dev-cpp-users mailing list > > > > > > > > > Dev...@li... > > > > > > > > > TO UNSUBSCRIBE: > > http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > Regards > > > > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Regards > > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > |
From: Jessica C. <jes...@gm...> - 2007-12-20 14:04:17
|
Hi, Per, Thanks. I asked my friend to see. He gave me the suggestion. The RegEnumValue can recognize the com and USB->COM. The problem solved now, I got the correct result: COM1(com), COM7(usb->com). In front of RegEnumValue, add: dwName = sizeof(Name); dwSizeofPortName = sizeof(szPortName); So the whole code is as follows (a bug in it: didn't release memalloc, but doesn't influence the result here). #include <windows.h> #include <stdio.h> #include <tchar.h> int main(void) { int z; char *strSerialList[256]; for (z=0; z<=256; z++) { strSerialList[z] = (char*)malloc(4096*sizeof(char)); } HKEY hKey; if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), 0, KEY_READ, &hKey) != ERROR_SUCCESS) { return -1; } int i=0; CHAR Name[4096]; UCHAR szPortName[4096]; LONG Status; DWORD dwIndex = 0; DWORD dwName; DWORD dwSizeofPortName; DWORD Type; dwName = sizeof(Name); dwSizeofPortName = sizeof(szPortName); do { dwName = sizeof(Name); dwSizeofPortName = sizeof(szPortName); Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, &Type, szPortName, &dwSizeofPortName); printf("Name=%s,szPortName=%s \n", Name, szPortName); if((Status == ERROR_SUCCESS) ) { strcpy(strSerialList[i],(char*)szPortName); //strSerialList[i] = (char*) szPortName; printf("%s ",strSerialList[i]); printf("i=%d,dwIndex=%d\n",i,dwIndex); i++; } } while((Status == ERROR_SUCCESS) ); RegCloseKey(hKey); printf("\n\n"); for(int j=0;j<i;j++) { printf("%s\n",strSerialList[j]); } return 0; } On Dec 19, 2007 6:02 PM, Per Westermark <pw...@ia...> wrote: > On an old test machine I have, the original code produces: > COM1 > COM1 > COM1 > COM1 > COM1 > COM1 > > After adding strdup(), I get: > COM5 > COM6 > COM7 > COM7 > COM4 > COM1 > > Are you sure that your change was correct, and that you remembered to > recompile? > > One interesting thing here is that COM7 is printed twice, while my much > used COM3 is not enumerated. > > The two COM7 seems to be a stupid M$ bug with an USB serial adapter :( > > /pwm > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > Hi, Per, > > > > for your second method, i modified like this. i doesn't solve the > > problem. the result is the same as before. > > for the first method, i tried to change strSerialList[i] = > > (char*)(szPortName); to strSerialList[i] = strdup((char*)(szPortName));, > but > > it seems doesn't work too. :-( > > > > Regards, > > Jessica > > > > do > > { > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > &Type, > > szPortName, &dwSizeofPortName); > > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > > { > > strSerialList[i] = (char*)(szPortName); > > printf("%s\n",strSerialList[i]); > > i++; > > } > > } while((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)); > > RegCloseKey(hKey); > > > > On Dec 19, 2007 2:44 PM, Per Westermark <pw...@ia...> wrote: > > > > > The test code is buggy. It uses the same buffer to retrieve the device > > > names, which means that the name will be overwritten. > > > > > > A quicky (with a memory leak that doesn't matter here) is to do > > > strSerialList[i] = strdup((char*)szPortName); > > > > > > Another alternative is to print the devices one-by-one directly when > they > > > are found. > > > > > > /pwm > > > > > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > > > > > Name Type Data > > > > (Default) REG_SZ (value not set) > > > > \Device\Serial0 REG_SZ COM1 > > > > \Device\U2SPORT1 REG_SZ COM7 > > > > > > > > if i used on my computer, i can see: > > > > COM1 > > > > COM1 > > > > > i> > > when i used my .exe on my colleagues computer. > > > > he has 2 serial port and 1 usb->serial. > > > > but we can only see "COM4" for 3 times. > > > > > > > > so at least, the code can recognize how many COM on computer, > whatever > > > real > > > > com port or usb-com. > > > > but cannot read right com port number. > > > > > > > > > > > > On Dec 19, 2007 1:57 PM, Rafael Menezes <so...@gm...> wrote: > > > > > > > > > Hi Jessica. > > > > > > > > > > Can you, for start, list what is on > "HARDWARE\\DEVICEMAP\\SERIALCOMM" > > > in > > > > > your computer? > > > > > > > > > > Regards > > > > > Rafael > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > > > > > > > > > Hi, thanks for ur email, Rafael. > > > > > > > > > > > > I researched myself. > > > > > > I wrote a code. I will list it as follows. > > > > > > The problem seems it can recognize the real serial com port (Com > 1 > > > in my > > > > > > computer, registry). > > > > > > But on my computer, I have a USB->serial com port (Com 7 in my > > > > > > computer, registry). > > > > > > The code cannot recognize the USB->serial com port. > > > > > > Is there any experienced persons can give any idea about that? > > > > > > > > > > > > #include <windows.h> > > > > > > #include <stdio.h> > > > > > > #include <tchar.h> > > > > > > > > > > > > int main(void) > > > > > > { > > > > > > char *strSerialList[256]; > > > > > > HKEY hKey; > > > > > > > > > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > > > > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > > > > > 0, > > > > > > KEY_READ, > > > > > > &hKey) != ERROR_SUCCESS) > > > > > > { > > > > > > return -1; > > > > > > } > > > > > > > > > > > > int i=0; > > > > > > CHAR Name[25]; > > > > > > UCHAR szPortName[25]; > > > > > > LONG Status; > > > > > > DWORD dwIndex = 0; > > > > > > DWORD dwName; > > > > > > DWORD dwSizeofPortName; > > > > > > DWORD Type; > > > > > > dwName = sizeof(Name); > > > > > > dwSizeofPortName = sizeof(szPortName); > > > > > > > > > > > > do > > > > > > { > > > > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, > NULL, > > > > > > &Type, > > > > > > szPortName, &dwSizeofPortName); > > > > > > if((Status == ERROR_SUCCESS) || (Status == > ERROR_MORE_DATA)) > > > > > > { > > > > > > strSerialList[i] = (char*)(szPortName); > > > > > > i++; > > > > > > } > > > > > > } while((Status == ERROR_SUCCESS) || (Status == > > > ERROR_MORE_DATA)); > > > > > > RegCloseKey(hKey); > > > > > > > > > > > > for(int j=0;j<i;j++) > > > > > > { > > > > > > printf("%s\n",strSerialList[j]); > > > > > > } > > > > > > > > > > > > return 0; > > > > > > } > > > > > > > > > > > > > > > > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> > wrote: > > > > > > > > > > > > > You can send mails. Can you search on google? > > > > > > > > > > > > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta = > > > > > > > > > > > > > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > > > > > > = > > > > > > > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm... > wrote: > > > > > > > > > > > > > > > is there anyone have the experience for writing code of > getting > > > the > > > > > > > > serial port info from windows? > > > > > > > > can u give me an sample code? > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > > > > > > SF.Net email is sponsored by: > > > > > > > > Check out the new SourceForge.net Marketplace. > > > > > > > > It's the best place to buy or sell services > > > > > > > > for just about anything Open Source. > > > > > > > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > Dev-cpp-users mailing list > > > > > > > > Dev...@li... > > > > > > > > TO UNSUBSCRIBE: > http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > Regards > > > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > Regards > > > > > Rafael Menezes > > > > > > > > > > > > > > |
From: Per W. <pw...@ia...> - 2007-12-19 23:02:28
|
On an old test machine I have, the original code produces: COM1 COM1 COM1 COM1 COM1 COM1 After adding strdup(), I get: COM5 COM6 COM7 COM7 COM4 COM1 Are you sure that your change was correct, and that you remembered to recompile? One interesting thing here is that COM7 is printed twice, while my much used COM3 is not enumerated. The two COM7 seems to be a stupid M$ bug with an USB serial adapter :( /pwm On Wed, 19 Dec 2007, Jessica Chen wrote: > Hi, Per, > > for your second method, i modified like this. i doesn't solve the > problem. the result is the same as before. > for the first method, i tried to change strSerialList[i] = > (char*)(szPortName); to strSerialList[i] = strdup((char*)(szPortName));, but > it seems doesn't work too. :-( > > Regards, > Jessica > > do > { > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, &Type, > szPortName, &dwSizeofPortName); > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > { > strSerialList[i] = (char*)(szPortName); > printf("%s\n",strSerialList[i]); > i++; > } > } while((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)); > RegCloseKey(hKey); > > On Dec 19, 2007 2:44 PM, Per Westermark <pw...@ia...> wrote: > > > The test code is buggy. It uses the same buffer to retrieve the device > > names, which means that the name will be overwritten. > > > > A quicky (with a memory leak that doesn't matter here) is to do > > strSerialList[i] = strdup((char*)szPortName); > > > > Another alternative is to print the devices one-by-one directly when they > > are found. > > > > /pwm > > > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > > > Name Type Data > > > (Default) REG_SZ (value not set) > > > \Device\Serial0 REG_SZ COM1 > > > \Device\U2SPORT1 REG_SZ COM7 > > > > > > if i used on my computer, i can see: > > > COM1 > > > COM1 > > > i> > > when i used my .exe on my colleagues computer. > > > he has 2 serial port and 1 usb->serial. > > > but we can only see "COM4" for 3 times. > > > > > > so at least, the code can recognize how many COM on computer, whatever > > real > > > com port or usb-com. > > > but cannot read right com port number. > > > > > > > > > On Dec 19, 2007 1:57 PM, Rafael Menezes <so...@gm...> wrote: > > > > > > > Hi Jessica. > > > > > > > > Can you, for start, list what is on "HARDWARE\\DEVICEMAP\\SERIALCOMM" > > in > > > > your computer? > > > > > > > > Regards > > > > Rafael > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > > > > > > > Hi, thanks for ur email, Rafael. > > > > > > > > > > I researched myself. > > > > > I wrote a code. I will list it as follows. > > > > > The problem seems it can recognize the real serial com port (Com 1 > > in my > > > > > computer, registry). > > > > > But on my computer, I have a USB->serial com port (Com 7 in my > > > > > computer, registry). > > > > > The code cannot recognize the USB->serial com port. > > > > > Is there any experienced persons can give any idea about that? > > > > > > > > > > #include <windows.h> > > > > > #include <stdio.h> > > > > > #include <tchar.h> > > > > > > > > > > int main(void) > > > > > { > > > > > char *strSerialList[256]; > > > > > HKEY hKey; > > > > > > > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > > > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > > > > 0, > > > > > KEY_READ, > > > > > &hKey) != ERROR_SUCCESS) > > > > > { > > > > > return -1; > > > > > } > > > > > > > > > > int i=0; > > > > > CHAR Name[25]; > > > > > UCHAR szPortName[25]; > > > > > LONG Status; > > > > > DWORD dwIndex = 0; > > > > > DWORD dwName; > > > > > DWORD dwSizeofPortName; > > > > > DWORD Type; > > > > > dwName = sizeof(Name); > > > > > dwSizeofPortName = sizeof(szPortName); > > > > > > > > > > do > > > > > { > > > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > > > > > &Type, > > > > > szPortName, &dwSizeofPortName); > > > > > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > > > > > { > > > > > strSerialList[i] = (char*)(szPortName); > > > > > i++; > > > > > } > > > > > } while((Status == ERROR_SUCCESS) || (Status == > > ERROR_MORE_DATA)); > > > > > RegCloseKey(hKey); > > > > > > > > > > for(int j=0;j<i;j++) > > > > > { > > > > > printf("%s\n",strSerialList[j]); > > > > > } > > > > > > > > > > return 0; > > > > > } > > > > > > > > > > > > > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> wrote: > > > > > > > > > > > You can send mails. Can you search on google? > > > > > > > > > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta = > > > > > > > > > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > > > > > = > > > > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm... > wrote: > > > > > > > > > > > > > is there anyone have the experience for writing code of getting > > the > > > > > > > serial port info from windows? > > > > > > > can u give me an sample code? > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > > > > SF.Net email is sponsored by: > > > > > > > Check out the new SourceForge.net Marketplace. > > > > > > > It's the best place to buy or sell services > > > > > > > for just about anything Open Source. > > > > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Dev-cpp-users mailing list > > > > > > > Dev...@li... > > > > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Regards > > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > Regards > > > > Rafael Menezes > > > > > > > > |
From: Jessica C. <jes...@gm...> - 2007-12-19 20:10:48
|
Hi, Per, for your second method, i modified like this. i doesn't solve the problem. the result is the same as before. for the first method, i tried to change strSerialList[i] = (char*)(szPortName); to strSerialList[i] = strdup((char*)(szPortName));, but it seems doesn't work too. :-( Regards, Jessica do { Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, &Type, szPortName, &dwSizeofPortName); if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) { strSerialList[i] = (char*)(szPortName); printf("%s\n",strSerialList[i]); i++; } } while((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)); RegCloseKey(hKey); On Dec 19, 2007 2:44 PM, Per Westermark <pw...@ia...> wrote: > The test code is buggy. It uses the same buffer to retrieve the device > names, which means that the name will be overwritten. > > A quicky (with a memory leak that doesn't matter here) is to do > strSerialList[i] = strdup((char*)szPortName); > > Another alternative is to print the devices one-by-one directly when they > are found. > > /pwm > > On Wed, 19 Dec 2007, Jessica Chen wrote: > > > Name Type Data > > (Default) REG_SZ (value not set) > > \Device\Serial0 REG_SZ COM1 > > \Device\U2SPORT1 REG_SZ COM7 > > > > if i used on my computer, i can see: > > COM1 > > COM1 > > > > when i used my .exe on my colleagues computer. > > he has 2 serial port and 1 usb->serial. > > but we can only see "COM4" for 3 times. > > > > so at least, the code can recognize how many COM on computer, whatever > real > > com port or usb-com. > > but cannot read right com port number. > > > > > > On Dec 19, 2007 1:57 PM, Rafael Menezes <so...@gm...> wrote: > > > > > Hi Jessica. > > > > > > Can you, for start, list what is on "HARDWARE\\DEVICEMAP\\SERIALCOMM" > in > > > your computer? > > > > > > Regards > > > Rafael > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > > > > > Hi, thanks for ur email, Rafael. > > > > > > > > I researched myself. > > > > I wrote a code. I will list it as follows. > > > > The problem seems it can recognize the real serial com port (Com 1 > in my > > > > computer, registry). > > > > But on my computer, I have a USB->serial com port (Com 7 in my > > > > computer, registry). > > > > The code cannot recognize the USB->serial com port. > > > > Is there any experienced persons can give any idea about that? > > > > > > > > #include <windows.h> > > > > #include <stdio.h> > > > > #include <tchar.h> > > > > > > > > int main(void) > > > > { > > > > char *strSerialList[256]; > > > > HKEY hKey; > > > > > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > > > 0, > > > > KEY_READ, > > > > &hKey) != ERROR_SUCCESS) > > > > { > > > > return -1; > > > > } > > > > > > > > int i=0; > > > > CHAR Name[25]; > > > > UCHAR szPortName[25]; > > > > LONG Status; > > > > DWORD dwIndex = 0; > > > > DWORD dwName; > > > > DWORD dwSizeofPortName; > > > > DWORD Type; > > > > dwName = sizeof(Name); > > > > dwSizeofPortName = sizeof(szPortName); > > > > > > > > do > > > > { > > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > > > > &Type, > > > > szPortName, &dwSizeofPortName); > > > > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > > > > { > > > > strSerialList[i] = (char*)(szPortName); > > > > i++; > > > > } > > > > } while((Status == ERROR_SUCCESS) || (Status == > ERROR_MORE_DATA)); > > > > RegCloseKey(hKey); > > > > > > > > for(int j=0;j<i;j++) > > > > { > > > > printf("%s\n",strSerialList[j]); > > > > } > > > > > > > > return 0; > > > > } > > > > > > > > > > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> wrote: > > > > > > > > > You can send mails. Can you search on google? > > > > > > > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta = > > > > > > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > > > > = > > > > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm... > wrote: > > > > > > > > > > > is there anyone have the experience for writing code of getting > the > > > > > > serial port info from windows? > > > > > > can u give me an sample code? > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > > SF.Net email is sponsored by: > > > > > > Check out the new SourceForge.net Marketplace. > > > > > > It's the best place to buy or sell services > > > > > > for just about anything Open Source. > > > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > > > > > > > _______________________________________________ > > > > > > Dev-cpp-users mailing list > > > > > > Dev...@li... > > > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > Regards > > > > > Rafael Menezes > > > > > > > > > > > > > > > > > > > > > -- > > > Regards > > > Rafael Menezes > > > > |
From: Per W. <pw...@ia...> - 2007-12-19 19:44:38
|
The test code is buggy. It uses the same buffer to retrieve the device names, which means that the name will be overwritten. A quicky (with a memory leak that doesn't matter here) is to do strSerialList[i] = strdup((char*)szPortName); Another alternative is to print the devices one-by-one directly when they are found. /pwm On Wed, 19 Dec 2007, Jessica Chen wrote: > Name Type Data > (Default) REG_SZ (value not set) > \Device\Serial0 REG_SZ COM1 > \Device\U2SPORT1 REG_SZ COM7 > > if i used on my computer, i can see: > COM1 > COM1 > > when i used my .exe on my colleagues computer. > he has 2 serial port and 1 usb->serial. > but we can only see "COM4" for 3 times. > > so at least, the code can recognize how many COM on computer, whatever real > com port or usb-com. > but cannot read right com port number. > > > On Dec 19, 2007 1:57 PM, Rafael Menezes <so...@gm...> wrote: > > > Hi Jessica. > > > > Can you, for start, list what is on "HARDWARE\\DEVICEMAP\\SERIALCOMM" in > > your computer? > > > > Regards > > Rafael > > > > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > > > Hi, thanks for ur email, Rafael. > > > > > > I researched myself. > > > I wrote a code. I will list it as follows. > > > The problem seems it can recognize the real serial com port (Com 1 in my > > > computer, registry). > > > But on my computer, I have a USB->serial com port (Com 7 in my > > > computer, registry). > > > The code cannot recognize the USB->serial com port. > > > Is there any experienced persons can give any idea about that? > > > > > > #include <windows.h> > > > #include <stdio.h> > > > #include <tchar.h> > > > > > > int main(void) > > > { > > > char *strSerialList[256]; > > > HKEY hKey; > > > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > > 0, > > > KEY_READ, > > > &hKey) != ERROR_SUCCESS) > > > { > > > return -1; > > > } > > > > > > int i=0; > > > CHAR Name[25]; > > > UCHAR szPortName[25]; > > > LONG Status; > > > DWORD dwIndex = 0; > > > DWORD dwName; > > > DWORD dwSizeofPortName; > > > DWORD Type; > > > dwName = sizeof(Name); > > > dwSizeofPortName = sizeof(szPortName); > > > > > > do > > > { > > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > > > &Type, > > > szPortName, &dwSizeofPortName); > > > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > > > { > > > strSerialList[i] = (char*)(szPortName); > > > i++; > > > } > > > } while((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)); > > > RegCloseKey(hKey); > > > > > > for(int j=0;j<i;j++) > > > { > > > printf("%s\n",strSerialList[j]); > > > } > > > > > > return 0; > > > } > > > > > > > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> wrote: > > > > > > > You can send mails. Can you search on google? > > > > > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta = > > > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > > > = > > > > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm... > wrote: > > > > > > > > > is there anyone have the experience for writing code of getting the > > > > > serial port info from windows? > > > > > can u give me an sample code? > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > SF.Net email is sponsored by: > > > > > Check out the new SourceForge.net Marketplace. > > > > > It's the best place to buy or sell services > > > > > for just about anything Open Source. > > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > > > > > _______________________________________________ > > > > > Dev-cpp-users mailing list > > > > > Dev...@li... > > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > -- > > > > Regards > > > > Rafael Menezes > > > > > > > > > > > > > > > -- > > Regards > > Rafael Menezes > |
From: Jessica C. <jes...@gm...> - 2007-12-19 19:18:38
|
Name Type Data (Default) REG_SZ (value not set) \Device\Serial0 REG_SZ COM1 \Device\U2SPORT1 REG_SZ COM7 if i used on my computer, i can see: COM1 COM1 when i used my .exe on my colleagues computer. he has 2 serial port and 1 usb->serial. but we can only see "COM4" for 3 times. so at least, the code can recognize how many COM on computer, whatever real com port or usb-com. but cannot read right com port number. On Dec 19, 2007 1:57 PM, Rafael Menezes <so...@gm...> wrote: > Hi Jessica. > > Can you, for start, list what is on "HARDWARE\\DEVICEMAP\\SERIALCOMM" in > your computer? > > Regards > Rafael > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > Hi, thanks for ur email, Rafael. > > > > I researched myself. > > I wrote a code. I will list it as follows. > > The problem seems it can recognize the real serial com port (Com 1 in my > > computer, registry). > > But on my computer, I have a USB->serial com port (Com 7 in my > > computer, registry). > > The code cannot recognize the USB->serial com port. > > Is there any experienced persons can give any idea about that? > > > > #include <windows.h> > > #include <stdio.h> > > #include <tchar.h> > > > > int main(void) > > { > > char *strSerialList[256]; > > HKEY hKey; > > > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > > 0, > > KEY_READ, > > &hKey) != ERROR_SUCCESS) > > { > > return -1; > > } > > > > int i=0; > > CHAR Name[25]; > > UCHAR szPortName[25]; > > LONG Status; > > DWORD dwIndex = 0; > > DWORD dwName; > > DWORD dwSizeofPortName; > > DWORD Type; > > dwName = sizeof(Name); > > dwSizeofPortName = sizeof(szPortName); > > > > do > > { > > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, > > &Type, > > szPortName, &dwSizeofPortName); > > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > > { > > strSerialList[i] = (char*)(szPortName); > > i++; > > } > > } while((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)); > > RegCloseKey(hKey); > > > > for(int j=0;j<i;j++) > > { > > printf("%s\n",strSerialList[j]); > > } > > > > return 0; > > } > > > > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> wrote: > > > > > You can send mails. Can you search on google? > > > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta = > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > > = > > > > > > > > > On 19/12/2007, Jessica Chen <jes...@gm... > wrote: > > > > > > > is there anyone have the experience for writing code of getting the > > > > serial port info from windows? > > > > can u give me an sample code? > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > SF.Net email is sponsored by: > > > > Check out the new SourceForge.net Marketplace. > > > > It's the best place to buy or sell services > > > > for just about anything Open Source. > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > > > _______________________________________________ > > > > Dev-cpp-users mailing list > > > > Dev...@li... > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > -- > > > Regards > > > Rafael Menezes > > > > > > > > > -- > Regards > Rafael Menezes |
From: Rafael M. <so...@gm...> - 2007-12-19 18:57:56
|
Hi Jessica. Can you, for start, list what is on "HARDWARE\\DEVICEMAP\\SERIALCOMM" in your computer? Regards Rafael On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > Hi, thanks for ur email, Rafael. > > I researched myself. > I wrote a code. I will list it as follows. > The problem seems it can recognize the real serial com port (Com 1 in my > computer, registry). > But on my computer, I have a USB->serial com port (Com 7 in my computer, > registry). > The code cannot recognize the USB->serial com port. > Is there any experienced persons can give any idea about that? > > #include <windows.h> > #include <stdio.h> > #include <tchar.h> > > int main(void) > { > char *strSerialList[256]; > HKEY hKey; > > if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, > TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), > 0, > KEY_READ, > &hKey) != ERROR_SUCCESS) > { > return -1; > } > > int i=0; > CHAR Name[25]; > UCHAR szPortName[25]; > LONG Status; > DWORD dwIndex = 0; > DWORD dwName; > DWORD dwSizeofPortName; > DWORD Type; > dwName = sizeof(Name); > dwSizeofPortName = sizeof(szPortName); > > do > { > Status = RegEnumValue(hKey, dwIndex++, Name, &dwName, NULL, &Type, > szPortName, &dwSizeofPortName); > if((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)) > { > strSerialList[i] = (char*)(szPortName); > i++; > } > } while((Status == ERROR_SUCCESS) || (Status == ERROR_MORE_DATA)); > RegCloseKey(hKey); > > for(int j=0;j<i;j++) > { > printf("%s\n",strSerialList[j]); > } > > return 0; > } > > > On Dec 19, 2007 12:34 PM, Rafael Menezes <so...@gm...> wrote: > > > You can send mails. Can you search on google? > > > > http://www.google.com.br/search?hl=pt-BR&q=c%2B%2B+com+port&meta= > > > > > > http://www.google.com.br/search?num=30&hl=pt-BR&q=c%2B%2B+serial+port&meta > > = > > > > > > On 19/12/2007, Jessica Chen <jes...@gm...> wrote: > > > > > is there anyone have the experience for writing code of getting the > > > serial port info from windows? > > > can u give me an sample code? > > > > > > > > > > > > ------------------------------------------------------------------------- > > > SF.Net email is sponsored by: > > > Check out the new SourceForge.net Marketplace. > > > It's the best place to buy or sell services > > > for just about anything Open Source. > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > -- > > Regards > > Rafael Menezes > > > -- Regards Rafael Menezes |
From: Jessica C. <jes...@gm...> - 2007-12-19 15:54:14
|
is there anyone have the experience for writing code of getting the serial port info from windows? can u give me an sample code? |
From: Per W. <pw...@ia...> - 2007-12-19 15:26:04
|
But I do have the answer. But I think you would have it too, if you look at the header file where the WM_CLOSE message is defined. You will find a huge number of other messages that you really want to know about, and a lot of status and configuration flags. Whenever you find an interesting message (or other symbol), it will then be trivial to google or directly visit MSDN to get the _exact_ information about when and how it is generated, or if there are version-specific notices about it, i.e. a level of information that we can't take the time to give you on this list. In short: My answer is about methodology. Few things are as giving as looking through the available header files. One hour with a couple of header files will pop your head full with ideas what you can do. After that, it is then trivial to flesh out the exact details about the solutions. You say that you have looked. My guess is that you forgot to look in the header files, in which case my previous mail did specifically point you in a very important direction. Life isn't always about getting explicit answers. The best answers you can get on mailing lists or forums are not explicit. The best answers you can get are the answers that solves a number of future problems too. In this case: where to look. In this case: google on "minimize size event" should as first match have told you about OnSizeChanged(). This might feel like a side track, but the word SIZE should feel very important. A bit closer look at the WM_SIZE message should have informed you that wParam can be SIZE_MINIMIZED. On the other hand: Looking for WM_CLOSE in the include files would have noticed it in winuser.h. Searching for MINIMIZE in winuser.h would match: #define WS_MINIMIZE 0x20000000 #define WS_MINIMIZEBOX 0x20000 #define SW_SHOWMINIMIZED 2 #define SW_MINIMIZE 6 #define SW_FORCEMINIMIZE 11 #define SM_CXMINIMIZED 57 #define SM_CYMINIMIZED 58 #define SPI_GETMINIMIZEDMETRICS 43 #define SPI_SETMINIMIZEDMETRICS 44 #define SIZE_MINIMIZED 1 #define SC_MINIMIZE 0xF020 #define HBMMENU_MBAR_MINIMIZE ((HBITMAP)3) #define HBMMENU_MBAR_MINIMIZE_D ((HBITMAP)7) #define HBMMENU_POPUP_MINIMIZE ((HBITMAP)11) typedef struct tagMINIMIZEDMETRICS { UINT cbSize; int iWidth; int iHorzGap; int iVertGap; int iArrange; } MINIMIZEDMETRICS,*LPMINIMIZEDMETRICS; A quick scan at these matches should also give a very good idea how to continue with google. They tell you such thing as how to configure a window to show a minimuze button, to allow minimizing, to make it minimized, to get the size of a minimized window, to catch the event when it gets minimized etc... Internet is large. To find something, you must develop a method how to search and where to start searching. Only then can you quickly drill down to the interesting parts. You are of course free to consider my answers bad, but learning how to search to be able to find the needed information in less than 5 minutes is quite a lot better than to have to spend 5 minutes writing a question and then have to wait hours or days for a possibly useful answer. /pwm On Wed, 19 Dec 2007, angel dario wrote: > The reason why i ask is not because i didn't took time to look it up on books, MSDN, or whatever comes to your mind. The reason i ask is because after i made a big search i couldn't find anything. GOT IT???????? > > And if you don't have the answer please don't answer with something else. > > thanks anyways. > _________________________________________________________________ > Share life as it happens with the new Windows Live. > http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_122007 |
From: angel d. <sci...@ho...> - 2007-12-19 14:28:50
|
The reason why i ask is not because i didn't took time to look it up on boo= ks, MSDN, or whatever comes to your mind. The reason i ask is because after= i made a big search i couldn't find anything. GOT IT???????? =20 And if you don't have the answer please don't answer with something else.=20 =20 thanks anyways. _________________________________________________________________ Share life as it happens with the new Windows Live. http://www.windowslive.com/share.html?ocid=3DTXT_TAGHM_Wave2_sharelife_1220= 07= |
From: Per W. <pw...@ia...> - 2007-12-19 09:23:44
|
Have you spent any time on the MSDN site, reading up on the documentation available there? Have you bought yourslf a good book on Win32 programming? Have you spent any time reading through the relevant header files - for example looking for all constants starting with WM_? /pwm On Tue, 18 Dec 2007, angel dario wrote: > > I want to know what's the message that is sended to the window when i cli= ck on the minimize button. > > For example: > When i click on the X button, it sends a WM_QUIT message to the procedu= re. > > _________________________________________________________________ > i=92m is proud to present Cause Effect, a series about real people making= a difference. > http://im.live.com/Messenger/IM/MTV/?source=3Dtext_Cause_Effect |
From: angel d. <sci...@ho...> - 2007-12-19 03:15:58
|
=20 I want to know what's the message that is sended to the window when i click= on the minimize button. =20 For example: When i click on the X button, it sends a WM_QUIT message to the procedure= . =20 _________________________________________________________________ i=92m is proud to present Cause Effect, a series about real people making a= difference. http://im.live.com/Messenger/IM/MTV/?source=3Dtext_Cause_Effect= |
From: Brad W. <c_b...@ya...> - 2007-12-17 04:08:14
|
Thank you very much, that fixed the problem. adrian <ad...@la...> wrote: Äîáðîãî âðåìåíè ñóòîê, c_b...@ya...! Âàìè, Brad Woosley áûëî íàïèñàíî: >I attempted to include , but I am told that there is no such file when I complie it. > Does this not come with Dev and I need to get it, or is there something else wrong with my code? > You can define IDC_STATIC as: #ifndef IDC_STATIC #define IDC_STATIC (-1) #endif Ñ óâàæåíèåì, ×óðèí. --------------------------------- Looking for last minute shopping deals? Find them fast with Yahoo! Search. |
From: Brad W. <c_b...@ya...> - 2007-12-17 03:50:54
|
I attempted to include <afxres.h>, but I am told that there is no such file when I complie it. Does this not come with Dev and I need to get it, or is there something else wrong with my code? adrian <ad...@la...> wrote: Äîáðîãî âðåìåíè ñóòîê, c_b...@ya...! Âàìè, Brad Woosley áûëî íàïèñàíî: >I have another problem with creating a dialog box using Win32. I am trying to get text to appear on the dialog box. Each time that I try to compile I am told that I am having a problem with 2 lines in the resource file. > > //LINE 1: > > GROUPBOX "Help for this program...",IDC_STATIC,7,7,225,52 > > //LINE 2: > > CTEXT "Insert help info here",IDC_STATIC,16,18,144,33 > > I am told that there is a parse error in these lines. I have windows.h included. > > Could some one tell me what I am doing wrong here. If needed, I will provide more of the program. I test your code by Resource Workshop and it found not any errors. But in dev-cpp you have to include , 'cos ID_STATIC implemented in this file. Ñ óâàæåíèåì, ×óðèí. --------------------------------- Never miss a thing. Make Yahoo your homepage. |
From: Unknown N. <unk...@gm...> - 2007-12-17 00:18:43
|
I decided to go 98 (found an old dusty copy in my attic...) Works fine n= ow. On Sun, 16 Dec 2007 09:58:20 -0500, <rus...@ao...> wrote: > > I can't speak with any > certainty, but I'd say that the win95 os is too old to run any of the > more recent versions (post 2000). You'd need to look at the versions > that were out at the time. In all honesty it'd be much better to pick > up win98/2000/xp. > > here's a good link for os (at pricewatch): > > http://www.pricewatch.com/software_oper_system/ > > > > > > > here's newegg's pricing: > > http://www.newegg.com/Store/SubCategory.aspx?SubCategory=3D368&name=3D= Operating-Systems > > > > > > > > btw.. does this feel like a loop to anyone else? ;) > > > > -----Original Message----- > From: Unknown Name <unk...@gm...> > To: dev...@li... > Sent: Sat, 15 Dec 2007 12:36 pm > Subject: [Dev-C++] Problem with Windows 95 > > > > > > > > > > > When I downloaded and installed Dev-Cpp 4.9.9.2 on my Windows 95 machi= ne, > which is version 4.0.950A, it said there were several DLL's missing, s= o I > downloaded and installed them. It didn't work after I did that, so I > uninstalled it and installed the older version avliable. Can someone > please help me. Any help would be glady appreciated. > > Thanks, > "Unknown Name" > -- = Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ |
From: <rus...@ao...> - 2007-12-16 14:58:39
|
I can't speak with any certainty, but I'd say that the win95 os is too old to run any of the more recent versions (post 2000). You'd need to look at the versions that were out at the time. In all honesty it'd be much better to pick up win98/2000/xp. here's a good link for os (at pricewatch): http://www.pricewatch.com/software_oper_system/ here's newegg's pricing: http://www.newegg.com/Store/SubCategory.aspx?SubCategory=368&name=Operating-Systems btw.. does this feel like a loop to anyone else? ;) -----Original Message----- From: Unknown Name <unk...@gm...> To: dev...@li... Sent: Sat, 15 Dec 2007 12:36 pm Subject: [Dev-C++] Problem with Windows 95 When I downloaded and installed Dev-Cpp 4.9.9.2 on my Windows 95 machine, which is version 4.0.950A, it said there were several DLL's missing, so I downloaded and installed them. It didn't work after I did that, so I uninstalled it and installed the older version avliable. Can someone please help me. Any help would be glady appreciated. Thanks, "Unknown Name" -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users ________________________________________________________________________ More new features than ever. Check out the new AOL Mail ! - http://webmail.aol.com |
From: Brad W. <c_b...@ya...> - 2007-12-16 05:54:53
|
I have another problem with creating a dialog box using Win32. I am trying to get text to appear on the dialog box. Each time that I try to compile I am told that I am having a problem with 2 lines in the resource file. //LINE 1: GROUPBOX "Help for this program...",IDC_STATIC,7,7,225,52 //LINE 2: CTEXT "Insert help info here",IDC_STATIC,16,18,144,33 I am told that there is a parse error in these lines. I have windows.h included. Could some one tell me what I am doing wrong here. If needed, I will provide more of the program. --------------------------------- Never miss a thing. Make Yahoo your homepage. |
From: Unknown N. <unk...@gm...> - 2007-12-15 17:37:34
|
When I downloaded and installed Dev-Cpp 4.9.9.2 on my Windows 95 machine, which is version 4.0.950A, it said there were several DLL's missing, so I downloaded and installed them. It didn't work after I did that, so I uninstalled it and installed the older version avliable. Can someone please help me. Any help would be glady appreciated. Thanks, "Unknown Name" -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ |
From: Jessica C. <jes...@gm...> - 2007-12-14 20:08:05
|
I am now dealing with multithreaded programming. one thread is RS232, another one is User Interface. The structure will be: User interface Thread ------> global variable(s)----> Worker thread Worker Thread ------> custom window message(s) ----> User interface Thread I don't know how to implement custom window messages! PostMessage, GetMessage, DispatchMessage? ===================================== REFERENCES: Now let's move to the communication methods between threads. There are three of them: * Using global variables * Windows messages * Event Threads share the process's resources including global variables so the threads can use global varibles to communicate with each other. However this method must be used with care. Thread synchronization must enter into consideration. For example, if two threads use the same structure of 10 members , what happens when Windows suddenly yanks the control from one of the thread when it was in the middle of updating the structure? The other thread will be left with an inconsistent data in the structure! Don't make any mistake, multithreading programs are harder to debug and maintain. This sort of bug seems to happen at random which is very hard to track down. You can also use Windows messages to communicate between threads. If the threads are all user interface ones, there's no problem: this method can be used as a two-way communication. All you have to do is defining one or more custom windows messages that are meaningful to the threads. You define a custom message by using WM_USER message as the base value say , you can define it like this: WM_MYCUSTOMMSG equ WM_USER+100h Windows will not use any value from WM_USER upward for its own messages so you can use the value WM_USER and above as your own custom message value. If one of the thread is a user interface thread and the other is a worker one, you cannot use this method as two-way communication since a worker thread doesn't have its own window so it doesn't have a message queue. You can use the following scheme: User interface Thread ------> global variable(s)----> Worker thread Worker Thread ------> custom window message(s) ----> User interface Thread In fact, we will use this method in our example. The last communication method is an event object. You can view an event object as a kind of flag. If the event object is in "unsignalled" state, the thread is dormant or sleeping, in this state, the thread doesn't receive CPU time slice. When the event object is in "signalled" state,Windows "wakes up" the thread and it starts performing the assigned task. Worker Thread ------> custom window message(s) ----> User interface Thread User interface Thread ------> global variable(s)----> Worker thread Worker Thread ------> custom window message(s) ----> User interface Thread |
From: Rafael M. <so...@gm...> - 2007-12-14 19:57:23
|
Thanks Per. Can you point me some directions or docs? I cant find any thing to fit my needs (almost the same you did... a simple GUI like a java applet, some buttons, etc). I will need a activex component to have access to the DOM? There is somewhere where I can see screenshots of what you have done? Thanks in advance Regards Rafael On 14/12/2007, Per Westermark <pw...@ia...> wrote: > > Yes, I have written C++ plugins that makes use of wxWidgets to display > property dialogs and graphs. I use it in a raytracer to allow the creation > of new object and surface types with integrated GUI for configuring and > previewing. > > The bad thing about C++ in a DLL is that the application and the plugins > should be compiled with the same C++ compiler, since most OS doesn't have > a standard ABI for C++ interoperability. > > /pwm > > On Thu, 13 Dec 2007, Rafael Menezes wrote: > > > Hi List > > > > Someone know or already done a c++ browser plug in with GUI (mean... c++ > > GUI)? I'm googling around for a couple of weeks and cant find anything > > useful. > > > > Another question: > > What is the fast way to parse a char[n]? I have a string like that: > > L 12/11/2007 - 15:56:45: "x6_Squibles<52><STEAM_0:1:3683971><TERRORIST>" > > attacked "x6_scottish<37><STEAM_0:1:1737><CT>" with "glock18" (damage > "72") > > (damage_armor "0") (health "28") (armor "0") > > > > and like to split in different, say rows in a XML file. I can write the > XML > > with no problem, but I'm stuck into many loops reading the string, see > if I > > already pick that value, if, then, for.... well... isn't beauty at all. > Its > > working, but way too complex. > > > > Thanks in advance. > > > > -- > > Regards > > Rafael Menezes > > > > -- Regards Rafael Menezes |
From: Per W. <pw...@ia...> - 2007-12-14 16:23:30
|
Yes, I have written C++ plugins that makes use of wxWidgets to display property dialogs and graphs. I use it in a raytracer to allow the creation of new object and surface types with integrated GUI for configuring and previewing. The bad thing about C++ in a DLL is that the application and the plugins should be compiled with the same C++ compiler, since most OS doesn't have a standard ABI for C++ interoperability. /pwm On Thu, 13 Dec 2007, Rafael Menezes wrote: > Hi List > > Someone know or already done a c++ browser plug in with GUI (mean... c++ > GUI)? I'm googling around for a couple of weeks and cant find anything > useful. > > Another question: > What is the fast way to parse a char[n]? I have a string like that: > L 12/11/2007 - 15:56:45: "x6_Squibles<52><STEAM_0:1:3683971><TERRORIST>" > attacked "x6_scottish<37><STEAM_0:1:1737><CT>" with "glock18" (damage "72") > (damage_armor "0") (health "28") (armor "0") > > and like to split in different, say rows in a XML file. I can write the XML > with no problem, but I'm stuck into many loops reading the string, see if I > already pick that value, if, then, for.... well... isn't beauty at all. Its > working, but way too complex. > > Thanks in advance. > > -- > Regards > Rafael Menezes > |