|
How to redirect com port data stream to my application.
|
|
|
|
|
You can read from the COm port using CreateFile() and ReadFile() . See here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for the reply. Actually I'm not reading/writing the com port but
intercept data sending to com port.
|
|
|
|
|
How?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
hi
i used a "file type extension " article to create one of my own.
everything is going well except for the registry Key Type Constants:
when i run it , there are 18 errors of the same type which is :
error C2199: syntax error : found 'const short (' at global scope (was a declaration intended?)
please help me . this is afinal step in my graduation project
thanks in advance
/////////////////////////////////////////////////////////////////
// Windows Registry Root Key Constants.
/* const int HKEY_CLASSES_ROOT = &H80000000; */
/* const int HKEY_CURRENT_CONFIG = &H80000005 ;*/
/* const int HKEY_CURRENT_USER = &H80000001; */
/* const int HKEY_DYN_DATA = &H80000006 ;*/
/* const int HKEY_LOCAL_MACHINE = &H80000002; */
/* const int HKEY_USERS = &H80000003 ;*/
// Windows Registry Key Type Constants.
const short REG_OPTION_NON_VOLATILE =0; // Key is preserved when system is rebooted
const short REG_DWORD =4; // 32-bit number
const short REG_EXPAND_SZ =2; // Unicode nul terminated string
const short REG_SZ =1 ; // Unicode nul terminated string
const short REG_BINARY =3 ; // Free form binary
const short REG_DWORD_BIG_ENDIAN =5 ; // 32-bit number
const short REG_DWORD_LITTLE_ENDIAN =4 ; // 32-bit number (same as REG_DWORD)
// Function Error Constants.
const short ERROR_SUCCESS =0;
const short ERROR_REG =1;
// Registry Access Rights.
const int SYNCHRONIZE = &H100000;
const int READ_CONTROL = &H20000;
const int STANDARD_RIGHTS_ALL = &H1F0000;
const int STANDARD_RIGHTS_READ = (READ_CONTROL);
const int STANDARD_RIGHTS_WRITE = (READ_CONTROL);
const short KEY_QUERY_VALUE = &H1;
const short KEY_SET_VALUE = &H2;
const short KEY_CREATE_LINK = &H20;
const short KEY_CREATE_SUB_KEY = &H4;
const short KEY_ENUMERATE_SUB_KEYS = &H8;
const short KEY_NOTIFY = &H10;
const int KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE));
const int KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE));
const int KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE));
const int KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE));
// Windows Registry API Declarations.
// Registry API To Open A Key.
int RegOpenKeyEx /*RegOpenKeyExA*/ (int hKey, Cstring lpSubKey, int u1Options, int samDesired, int& phkResult); //"advapi32.dll"
// Registry API To Create A New Key.
int RegCreateKeyEx /*RegCreateKeyExA*/ (int hKey, CString lpSubKey, int Reserved, CString lpClass, int dwOptions, int samDesired, int lpSecurityAttributes, int& phkResult, int lpdwDisposition);//"advapi32.dll"
// Registry API To Query A String Value.
int RegQueryValueExString /*RegQueryValueExStringA */ (int hKey, CString lpValueName, int lpReserved, int& lpType, CString lpData, int& lpcbData);//"advapi32.dll" Alias "RegQueryValueExA" _
// Note that if you declare the lpData parameter as String, you must pass it By Value.
//Registry API To Query A Long (DWORD) Value.
int RegQueryValueExLong /* RegQueryValueExLongA */(int hKey, CString lpValueName, int lpReserved, int& lpType, int& lpData, int& lpcbData); //"advapi32.dll"
// Registry API To Query A NULL Value.
int RegQueryValueExNULL /* RegQueryValueExA */ (int hKey, CString lpValueName, int lpReserved, int& lpType, int lpData, int& lpcbData);//"advapi32.dll"
// Registry API To Set A String Value.
int RegSetValueExString /* RegSetValueExA */(int hKey, CString lpValueName, int Reserved, int dwType, CString lpValue, int cbData);// "advapi32.dll"
// Note that if you declare the lpData parameter as String, you must pass it By Value.
// Registry API To Set A Long (DWORD) Value.
int RegSetValueExLong /* RegSetValueExA */ (int hKey, CString lpValueName, int Reserved, int dwType, int& lpValue, int cbData);//"advapi32.dll"
// Registry API To Delete A Key.
int RegDeleteKey /* RegDeleteKeyA */ (int hKey, CString lpSubKey); //"advapi32.dll"
// Registry API To Delete A Key Value.
int RegDeleteValue /* RegDeleteValueA */ (int hKey, CString lpValueName ); //"advapi32.dll"
// Registry API To Close A Key.
int RegCloseKey (int hKey); // "advapi32.dll"
//Constants For Error Messages.
const CString OpenErr = "Error: Opening Registry Key!";
const CString DeleteErr = "Error: Deleteing Key!";
const CString CreateErr = "Error: Creating Key!";
const CString QueryErr = "Error: Querying Value!";
#endif // !defined(AFX_FILE_COMMANDS_
//////////////////////////////////////////////////
lahom
|
|
|
|
|
lahom wrote: error C2199: syntax error : found 'const short (' at global scope (was a declaration intended?)
See here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
thanks
but I have seen this "link" before and i couldn't figure that out in my problem .
I tried to define the register type key first then assign it to some value like this:
const short REG_OPTION_NON_VOLATILE;<br />
REG_OPTION_NON_VOLATILE =0; but it didnt work .
so iam stuck now at this point.
pleeease ... help me
again ...thank u.
lahom
|
|
|
|
|
lahom wrote: const short REG_OPTION_NON_VOLATILE;
REG_OPTION_NON_VOLATILE =0;but it didnt work .
This has already been defined in winnt.h .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am having trouble setting the precision of a double in a Windows Forms Application. I would like to set the value of temp in this label to 2 decimal places. I know there's an easy fix for this, but after searching I just can't find how to do it.
label4->Text = "The output of your conversion is: " + temp + "\u00B0";
Thanks for the help!
|
|
|
|
|
You have to do temp.ToString("format-string"). Check the help of Double.ToString[^] for more details.
-Saurabh
|
|
|
|
|
Hi
I am new to Vsual studio....
anyone know which control can be used for displaying text,image as well as Link....
Please Help me...
Thanks and Regards
Simnesh
|
|
|
|
|
I believe that would be a static control.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Greetings,
I thought this:
hbmTiles = WinGCreateBitmap(hdcBackbuffer, &bmi, (void**)&ptrTiles);
...would put the pixel data of hbmTiles into ptrTiles . And it works, the pointer does indeed contain the correct pixel information, but if I write to it, nothing happens to the original bitmap. How can I apply this back to the bitmap?
Thanks in advance!
Windows Calculator told me I will die at 28.
|
|
|
|
|
I have written a C++ Windows program called MAKEOBJ. It is a CGI mesh handling program. Under Windows Vista it is displaying an odd bug. In it, when I call SetPixel(dc,x,y,color), the pixel seems to be set only if (x&256)==0. This x is relative to the program's window, not to the whole screen. This happens with my MAKEOBJ's old Borland C++ version (which behaved OK under Windows 98 on my old computer) and with my new Visual C++ version. (Line drawing, and copying an image to the screen, work OK.) Please what is happening and how to cure it?
The same also happens with a completely different program that I wrote, to handle 2D graphics images.
modified on Sunday, April 20, 2008 2:55 PM
|
|
|
|
|
Try GetLastError and see what is the error returned from GetPixel, if any?
-Saurabh
|
|
|
|
|
I think may be it comes with compiler problem ..
|
|
|
|
|
|
The cause is not a "compiler issue", because it happens with Visual C and Borland C, as my first message in this thread says.
Could the cause be a replacement screen-driver which I had to download and install? The fault symptoms are relative to the affected program's window, not to the whole screen. Line-drawing and BitBlt and similar seem to run OK.
|
|
|
|
|
I have hacked a temporary solution, thus, but I would prefer a proper permanent solution:
void Set_Pixel(HDC dc,int x,int y,COLORREF c);
#define SetPixel(dc,x,y,c) Set_Pixel(dc,x,y,c)
/*-----*/
void Set_Pixel(HDC dc,int x,int y,COLORREF c){
HPEN p=CreatePen(PS_SOLID,1,c),q; q=(HPEN)SelectObject(dc,p);
MoveToEx(dc,x,y,0); LineTo(dc,x,y+1); SelectObject(dc,q); DeleteObject(p);}
|
|
|
|
|
Thanks a lot. This works !
|
|
|
|
|
Hi, I want to know how to detect USB masstorage device when I insert it (in console application), and then get serial number of device?
|
|
|
|
|
Hi,
I've just started looking at c++ and I'll probably be buying a book in a few days. Right now I'm trying to make a simple Hello World program but I'm not sure how to compile it. I'm using Visual C++ 2008 Express Edition, just created a new .cpp file and wrote the code in it but where do I go from here?
helloworld.cpp:
#include <iostream><br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
cout << "Hello World!\n";<br />
return 0;<br />
}
|
|
|
|
|
The simplest way (AFAIK): create a new project (choose console application), Visual Studio will create header and source files for you. Write your code inside the .cpp one, compile and enjoy it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thank you, that worked. But why did it create another 20 files? Is there not a way to compile just one single .cpp-file as it is?
|
|
|
|
|