|
IamJimW wrote:
I've tried using CreateFile() to get access to the port, but I get a "port in use" error
As far as I know, there's no way to do this. It's possible a replacement serial port driver could support something like this.
It's probably easier to use a 'breakout' program on another PC, listening to the RS-232 traffic via a 'Y' cable. Take a look at this[^], for example.
Software Zen: delete this;
|
|
|
|
|
Jim,
I don't know how to do this from Visual C++, but I believe that it can be done. A product that I purchased not too long ago does just that. It is called "Advanced Serial Port Monitor" and is available from here:
http://www.aggsoft.com/products/supercom/
I believe they also offer a software development kit that might be just what you need. The product is great too.
Robert
|
|
|
|
|
Check out PortMon at sysinternals.com
I don't think they give away the source, but they do talk in detail about inserting a driver to intercept such stuff. That is probably what you need.
Or you could brute-force it by reading the window displayed by PortMon. But that sure would be ugly!
Good luck!
|
|
|
|
|
Thanks everyone for your help.
It looks like a too-hard in VC++.
The solution looks to be one of the programs around that redirect the com port to an IP address, or use a cable splitter.
Jim
|
|
|
|
|
I have a c style function that calls windows api
to get the size of the menu item string.
mi.cbSize = sizeof(MENUITEMINFO);
mi.fMask = MIIM_TYPE;
mi.fType = MFT_STRING;
mi.dwTypeData=NULL;
GetMenuItemInfo(hMenu, 1, true, _mi);
This generates an Access violation in user32.dll.
How can I find out info or trap the exception in c
to see what is going on?
|
|
|
|
|
make sure you do zeromemory on the mi structure before you use it.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Maybe I should clarify that I am trying to do this from another process.
void getMenuItem(HWND hWndMenu)
{
HMENU menu = GetMenu(hWndMenu);
MENUITEMINFO mi, *_mi; unsigned long pid;
HANDLE process;
GetWindowThreadProcessId(hWndMenu, &pid);
process=OpenProcess (PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid);
_mi=(MENUITEMINFO*)VirtualAllocEx(process, NULL, sizeof(MENUITEMINFO), MEM_COMMIT, PAGE_READWRITE);
ZeroMemory(&mi, sizeof(MENUITEMINFO));
mi.cbSize = sizeof(MENUITEMINFO);
mi.fMask = MIIM_TYPE;
mi.fType = MFT_STRING;
mi.dwTypeData=NULL;
WriteProcessMemory(process, _mi, &mi, sizeof(MENUITEMINFO), NULL);
// this fails GetMenuItemInfo(menu, 1, true, _mi);
ReadProcessMemory(process, _mi, mi, sizeof(MENUITEMINFO), NULL);
int size = mi.cch;
VirtualFreeEx(process, _mi, 0, MEM_RELEASE);
|
|
|
|
|
All,
I have created a combo box from the same set of parameters used to create a previous combo box. I hace verified that they have the same properties. Here are the properties. All "False" except where noted:
Data: empty box
ID: IDC_TRIGGERING
Owner Draw: No
Tabstop: True
Type: Drop List
Vertical Scrollbar: True
Visible: True
The idea is that I wish to present the user with a fixed list of values to choose from. The code to add items to the list is as follows:
nTriggerMode = GetPrivateProfileInt("Settings", "Triggering Mode", 0, "sdkdemo.ini");
lResult = SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_ADDSTRING, 0, (long)"10");
lResult = SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_ADDSTRING, 0, (long)"15");
SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_ADDSTRING, 0, (long)"20");
SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_SETCURSEL, nTriggerMode, 0);
The lResult variable is being incremented as the numbers are being added to the combo box, so that appears to be working. The value of nTriggerMode is pulled out of a file and whatever value it is set to initially (0, 1 or 2) successfully controls which of the three items is first shown in the display (10, 15 or 20).
Life is good...
Except, when I try and use the combo box by left clicking in the pulldown on the right of the box, nothing happens except that I get a narrow black line (1/16 inch) that appears under the combo box. The line then disappears when I click the pulldown again. The list of 3 items never appears.
I don't believe that I need to process messages for the combo box. The other application didn't. When I want to know what value the user has most recently entered I just do the following:
nTriggerMode = SendMessage(GetDlgItem(hdlg, IDC_TRIGGERING), CB_GETCURSEL, 0, 0);
Any ideas?
Robert
P.S. I am not using MFC in this code.
|
|
|
|
|
You need to set the size of the drop down list, for some idiotic reason it defaults to this zero value. At least, that's what happens when designing the dialog box using MFC. I have no idea how to do it in Win32, or even programatically, I always did it in the form designer.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Setting the size of the combo box is bit tricky if you havent done it before...
by default you can only resize horizontally... ifyou want to do vertical resizing click on the arrow key and then you can resize vertically.... (all this in form design view).
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Mr. Prakash,
Thanks, I found a similar answer in another thread, from another Indian guy
In the resource editor if you click in the middle of the combo box, blue squares appear on the left and right, allowing you to make the box wider or narrower. But, if you click on the pulldown itself, there is a single blue box in the bottom center. Grabbing that blue box and pulling it down defines what size the combo box is when initially displayed.
Too bad they don't say anything about this in the help area...
Actually, it is explained. It is under "Combo Boxes" then "sizing".
Robert
|
|
|
|
|
What's wrong with my code ?
CString PrintName;
PRINTER_INFO_1 PrintInfo[3];
LPDWORD pNeedSize;
LPDWORD pPrinters;
DWORD cbSize;
cbSize = sizeof(PrintInfo);
if ( EnumPrinters(PRINTER_ENUM_NAME,(LPTSTR)&PrintName,1,(LPBYTE)PrintInfo,cbSize,pNeedSize,pPrinters) != 0 )
{
this->MessageBox("SUCC");
}
else
{
int err = ::GetLastError();
this->MessageBox("fail");
}
d
|
|
|
|
|
One thing i can see is
CString PrintName;
...
EnumPrinters(PRINTER_ENUM_NAME,(LPTSTR)&PrintName,1,(LPBYTE)PrintInfo,cbSize,pNeedSize,pPrinters)
it should be
EnumPrinters(PRINTER_ENUM_NAME,PrintName.GetBuffer(100),1,(LPBYTE)PrintInfo,cbSize,pNeedSize,pPrinters)
Is there anyother error that you get ?
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
I think you need to call EnumPrinters twice, the first time to find out how much memory is required to store the information returned, and the second time to actually get that information.
It probably doesn't work unless you allocate enough memory for the information returned.
Also, to enumerate all printers, use PRINTER_ENUM_LOCAL
refer MSDN for details
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_9fjn.asp[^]
sample code
DWORD dwSizeNeeded = 0;
DWORD dwPrinterCount = 0;
BOOL bEnumResult;
CString strErr;
HANDLE hProcessHeap = GetProcessHeap();
LPPRINTER_INFO_2 lpPrinterData;
EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &dwSizeNeeded, &dwPrinterCount);
if ((lpPrinterData = (LPPRINTER_INFO_2)HeapAlloc(hProcessHeap,
HEAP_ZERO_MEMORY, dwSizeNeeded)) == NULL)
{
return;
}
bEnumResult = EnumPrinters (PRINTER_ENUM_LOCAL,
NULL,
2,
(LPBYTE)lpPrinterData,
dwSizeNeeded,
&dwSizeNeeded,
&dwPrinterCount);
if (bEnumResult) {
if (dwPrinterCount == 0) {
HeapFree(hProcessHeap, 0, lpPrinterData);
return;
}
}
HeapFree(hProcessHeap, 0, lpPrinterData);
return;
|
|
|
|
|
if i just use broadcast to send data , and i didn't use socket to connect ,can someone teach me how can i to handle the data of response in the broadcast plz and thank u.
|
|
|
|
|
Since you dont make socket connection with individual pc you cant have serv/responce kinda architecture... I belive you are using DGRAM/UDP Sock. In this case you should consider each communication as independent from anyother communication....
Onething you can do is have Packet type for each UDP transer. so that you know that this packet is in response to some packet you had send earlier....
I hope I helped you in someway.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Yes, you are right.
But i still no idea how to get the packet...
I know i should receive the packet in one selected port,but i don't know how to do it...
can anyone help me plz?
|
|
|
|
|
Click Click[^]
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
there are many kinds of broadcast, for example 192.168.0.255 is a broadcast for the net 192.168.0.x.
the biggest possible broadcast is 255.255.255.255, every computer in the net will receive and parse this. so the way is to bind the udp sockets on addresses like INADDR_ANY.
Don't try it, just do it!
|
|
|
|
|
this is my code
WSADATA data;
WORD version;
SOCKET socket_sd;
struct sockaddr_in s_to,s_sourse;
version = (MAKEWORD(2,2));
WSAStartup(version,&data);
s_sourse.sin_family = AF_INET;
s_sourse.sin_port = htons(64513);
s_sourse.sin_addr.s_addr = htonl(INADDR_ANY);
s_to.sin_family = AF_INET;
s_to.sin_port = htons(64515);
s_to.sin_addr.s_addr = htonl(INADDR_ANY);
socket_sd = socket(AF_INET, SOCK_DGRAM, 0);
bind(socket_sd, (struct sockaddr far *)&s_sourse, sizeof(s_sourse));
sendto( socket_sd, (char *)&sendbuf,sizeof(sendbuf), 0, (struct sockaddr far *)&s_to, sizeof(s_to) );
can anyone tell me why i can't send the broadcast plz???
|
|
|
|
|
I'm using CWebBrowser2 in a dialog and would like to prevent the user from being able to go back, forward and change the font size by clicking Alt-LeftArrow, Alt-RightArrow and using the mousewheel. Does anyone know how to do this? Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
when I compile my program all are ok.
And when I execute my program an error appear :
dlgdata.cpp error in line 43
I have 2 PCs with VC++ and I have the same problem when I executed the program.
Best Regards
youssef
|
|
|
|
|
You're hitting an ASSERT because you're trying to bind via DDX to a nonexistent control. (Shameless self-promotion) this article[^] will help you understand how to understand and debug these kinds of problems.
Rob Manderson
Colin Davies wrote: I'm sure Americans could use more of it, and thus reduce the world supply faster. This of course would be good, because the faster we run out globally, the less chance of pollution there will be. (Talking about the price of petrol) The Soapbox, March 5 2004
|
|
|
|
|
You are right .
|
|
|
|
|
Hi. Currently I have a Visual C+ program that communicates with a GPS device through a serial-to-USB interface. Analysis of the GPS information leads to a set of control signals being sent to a Motorola HC12 Microcontroller. I was wondering if anyone had any ideas on how this process could take place. Basically the micro controls acceleration and steering for an autonomous vehicle I am working on. From the micro, 5 volts control an analog switch varying +/- 12 volts to a steering motor and alos from the micro a bit signal that sets the correct wiper setting in the digital potentiometer. I need a way to send a signal from the Windows XP laptop I am using to the microcontroller through a serial port. I am using the MarshallSoft GPS DLL to manipulate the USB port that the GPS information comes into. Since I have a serial-to-usb conversion acting on COM4, how do I take control of Com1 lets say and send a particular bit pattern to the micro?????Any help would greatly be appreciated.
|
|
|
|
|