|
hello everyone, i still understand this question:
char a = '1';
printf("%d",a ); //can get 49
printf("%c",a ); //can get 1
how can i know why it can printf 49?? somethings have between about char and int ??????
thank you
|
|
|
|
|
See here what is the Ascci decimal for character '1'. Hope you get a clue on how characters are stored in memory while using 8 bit char datatype. Otherwise go for some good books.
|
|
|
|
|
printf("%d",a );
This line says print the decimal value of variable a; since a contains the character '1' it prints the ASCII value, which is 0x31 or 49 decomal.
printf("%c",a );
This says print the character stored in variable a, which is the character '1'.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi Experts,
I am facing a strange problem.
I developed a simple COM dll in VS2008 using ATL on vista 32 bit platerform. When I try to register it on windows server 2008, I am getting below error.
The module "D:\TestATL.dll" failed to load.
Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail.
I searched this problem on google but could not find any solution. Any idea about this.
Solution: http://www.codeguru.com/forum/showthread.php?t=454296
Thanks
Manish
modified on Saturday, November 27, 2010 1:08 AM
|
|
|
|
|
hello
i want to see all files in directory dir that have .txt and rename them to directory dir2 with suffix .cpp how i can do this??
|
|
|
|
|
|
can you write the code of it here?
|
|
|
|
|
If you took the trouble to go and look at the links that Cool_Dev provided you would see some sample code to help you.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Note that people sometimes forget about FindClose() thus leaking a handle. Another important thing is that when FindFirstFile() returns INVALID_HANDLE_VALUE and when FindNextFile() returns FALSE you may want to check if GetLastError() returns ERROR_NO_MORE_FILES or something more brutal.
|
|
|
|
|
void txt2cpp(const TCHAR* path)
{
TCHAR full[_MAX_PATH+_MAX_FNAME];
TCHAR move[_MAX_PATH+_MAX_FNAME];
unsigned int flen;
unsigned int mlen;
HANDLE hf;
WIN32_FIND_DATA fd;
_tcscpy(full,path); flen = _tcslen(full); _tcscpy(full+flen,_T("\\*.txt"));
hf = FindFirstFile(full);
if(INVALID_HANDLE_VALUE!=hf)
{
do
{
if(!(FILE_ATTRIBUTE_DIRECTORY & fd.dwFileAttributes))
{
_tcscpy(full+flen+1,fd.cFileName);
_tcscpy(move,full); mlen = _tcslen(move);
for(;(0<mlen)&&('.'!=move[mlen-1]);mlen--);
_tcscpy(move+mlen,_T("cpp"));
MoveFile(full,move);
}
} while(FindNextFile(hf,&fd));
FindClose(hf);
}
}
comment: not safe for buffer overflow.
|
|
|
|
|
|
When using MFC, we can create dll usign MFC, and create MFC dialog or MFC windows in DLL. And Shows the dialog or windows by export functions.
But how to use WTL in dll? WTL AppWizard can only create exe project, ATL has no enough UI support. What can we do to usign WTL in dll? Create WTL dialogs and WTL windows and other WTL UI components.
Thanks
|
|
|
|
|
Hi,
tank0 wrote: What can we do to usign WTL in dll?
WTL is a template library and as you certainly know templates are compiled when used, not when declared. Thus it is impossible to export uninstanciated template classes from a dll.
That said, you can use WTL in dlls which export only fully instanciated templates like WTL_DLL.ZIP
in the Files section of the WTL support list[^].
Another example is here[^].
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Alain Rist wrote: WTL is a template library and as you certainly know templates are compiled when used, not when declared. Thus it is impossible to export uninstanciated template classes from a dll.
That said, you can use WTL in dlls which export only fully instanciated templates like WTL_DLL.ZIP in the Files section of the WTL support list[^].
Another example is here[^].
cheers,
AR
Thanks for your reply. What I what to do is just like you said.
Export a single function in the dll such as ShowDlg()
What the ShowDlg function do is that creates a modal window and shows.
With MFC, I can just create a "Regular DLL with MFC statically linked" project and in the project use codes like below is enough.
But I don't know what to do with WTL. WTL appwizard can only create exe projects.
extern "C" __declspec(dllexport) void ShowDlg()
{
CDialog dlg(IDD_Dialog1);
dlg.DoModal();
}
|
|
|
|
|
Use an AppWiz generated Win32 dll with the code from a WTL application. Study the referenced WTL_DLL.ZIP code, it's really simple and does exactly what you wish
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
I got it, thanks for your help
|
|
|
|
|
You are welcome
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Hi ,
I am creating BHO component in which I used DWebBrowserEvents2 interface and overrides its
OnQuit() function. When i test this function on IE8 on Vista, it called on my machine but does not called on other machine with same configuration. What may be the problem for not calling onQuit() function on other machine.
Does this mean that IE8 is not installed properly on other machine, or there is need to installed windows update for this.
please let me know how IE8 behavior change from machine to machine.
Thanks
Atul
|
|
|
|
|
Documentation states OnQuit 'Fires before the Windows Internet Explorer application quits'. May be you can check if the IE has actually quit.
|
|
|
|
|
I am writing an application wherein I need to scan the computer to see if either of two different USB devices are attached. The first device appears as a HID, and the second device appears as a virtual COM port. Which WMI classes should I be checking to see if each device is attached?
I am using this for the HID:
m_bstrScope = SysAllocString( _T("root\\CIMV2") );
m_bstrQuery = SysAllocString( _T("SELECT PNPDeviceID FROM Win32_PnPEntity") );
...and this for the virtual COM port device:
m_bstrScope = SysAllocString( _T("root\\CIMV2") );
m_bstrQuery = SysAllocString( _T("SELECT DeviceID,PNPDeviceID FROM Win32_SerialPort") );
This pseudo code shows how my scanning algorithm works:
if ( ScanForDevice1() )
{
}
else if ( ScanForDevice2() )
{
}
else
{
}
This seems to work, except when I change which device is connected between running the application. If device 1 is found, the scan for device 2 is aborted; the scan for device 2 only occurs if device 1 is not found. What happens is this:
- The application is run with both devices attached to the system. Device 1 is found, as expected. The application exits.
- Device 1 is unplugged from the system.
- The application is run with only device 2 attached to the system. Oddly, device 1 is found, even though it is not attached. The application exits.
- Both devices are unplugged from the system.
- The application is run with no devices attached. No devices are found, as expected. The application exits.
- Only device 2 is plugged back into the system.
- The application is run with only device 2 attached. The application finds device 2, as expected.
My best guess is that I am querying the wrong class(es). Which classes should my application be checking? Or, is there something else that I should be doing? Thanks.
|
|
|
|
|
one com interface function :
class IProtocolImp : public IUnknown
{
.....
GetRegisters( char *szDeviceName[int], LPVOID *ppReg[out] , int *pRegNum[out] );
// Get registers name and number
......
}
typedef struct reginfo
{
char sRegName[8];//register's name
int nLowIndex;
int nUpperIndex;
WORD wDataType;//
int nData;
}REG_INFO;
i call this in my project,
IProtocolImp * pf;
int RegNum;
REG_INFO * BASED_CODE pRegInfos[256];
HRESULT res=::CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,IID_ProtocolImp,(void * *)&pf);
if(res == S_OK)
{
pf->GetRegisters("MyDevice",(LPVOID *)pRegInfos,&RegNum);
}
if program is correct,will return
RegNum=2;
gsRegInfos[0]={"DATA1", 0, 15, 100, 0};gsRegInfos[1]={"DATA2", 0, 15, 100,0};
but program has a problem,
RegNum=2;//this correct
gsRegInfos[0]={"DATA1", 0, 15, 100, 0};gsRegInfos[1]=0xcccccccc;//this a problem
why ????
it is com code:
"xxx.h"
static REG_INFO BASED_CODE gsRegInfos[]=
{
{"DATA1", 0, 15, 100, 0};
{"DATA2", 0, 15, 100, 0};
};
"xxx.cpp"
STDMETHODIMP_(BOOL) MYDLLPro::XProtocolImp::GetRegisters(char *szDeviceName,LPVOID * ppRegs, int *pRegNum)
{
METHOD_PROLOGUE(MYDLLPro, ProtocolImp);
*ppRegs = (LPVOID)&gsRegInfos;
*pRegNum = sizeof(gsRegInfos)/sizeof REG_INFO;//REG_TYPE_NUM
return TRUE;
}
|
|
|
|
|
It's not easy to read your question. Please edit the message and put <pre></pre> tags around he code blocks so they can be read more easily. From a quick glance it looks like your indexing is not working properly, check the pointer indexing in your GetRegisters() function.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Perhaps if you formatted your code so it's readable?
Steve
|
|
|
|
|
I'm a new one, which want to learn linux. but i do't how to study it.
i have use ubuntu some days.but i find i use it like windows. i don't
understand somethings about linux,but just use g++.
I want to be a coder in linux, so give me some advices , thank you very
much
|
|
|
|
|
Here, perhaps this will get you started: Programming for Linux[^]
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|