Re: VS2005 compatibility
- From: Long <Long@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 5 Sep 2006 13:43:01 -0700
I don't think I was using an emulator, because I can download the program to
the target device to run it (first example) or copy the program manually to
the device and run it.
As for the Workspace I mentioned, actually the two example are using the
same project "workspace". I just modified the _tmain() function to call APIs
or use the CReg. So the project settings should be the same. They are all
compiled successfully. The only differece is one can run and the other not.
I don't know how to attached the exe here. I cannot find any other options.
"Paul G. Tobey [eMVP]" wrote:
2. In this wizard, you adjusted things so that the targets listed are just.
your specific device?
Are you sure you're not building for the Colibri emulator? That would be an
x86 EXE, not ARM, as needed for the real device. Project settings are not
attached to a workspace; they are part of the project. If the project was
not generated as a Smart Device application, you've found your problem.
You can attach the EXE itself and I'll see what the headers look like, but
the system works well, generally, so you're doing something way off the
track...
Paul T.
"Long" <Long@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5EDFDEB1-4B4D-4869-A0D4-02278F09E4A7@xxxxxxxxxxxxxxxx
I must make some mistakes when typing the second examples, i.e. ValueDW(),
instead of copying and pasteing the code. I think I did the same as you
did
except my program cannot run. This is what I did.
1. Create a Smart Device project.
2. Remove the default device and select my device: Colibri.
3 Select Console Application. ATL, MFC and Empty project are unchcked.
4. Then finish thw wizard. Everything is in default settings.
5. Then type in my code, compile and run with or without debugging.
These projects do not need additional libraries. But I don't know what
default libs they use. So I don't think I change them. Besides I use the
same workspace and settings to compile the two examples, one can run and
the
other doesn't. If that is not a problem from VS2005, would that comes
from
BSP or its SDK?
"Paul G. Tobey [eMVP]" wrote:
And a thought arises. What libraries are you linking with? Did you
change
anything from the default generated by the VS2005 new project wizard to
target Smart Devices?
Paul T.
"Long" <Long@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:491D9629-7A31-4251-AA3F-DCF47D434F4A@xxxxxxxxxxxxxxxx
Thanks Paul,
Here is the code without problems.
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
int _tmain(int argc, _TCHAR* argv[])
{
wprintf(L"Starting...\n");
HKEY m_hKey;
int m_Index;
LPBYTE m_lpbValue; // last value read, if any
//TCHAR szValue[MAX_PATH];
DWORD ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Comm", 0, KEY_READ,
&m_hKey);
DWORD dwValue = 1;
DWORD dwLen = sizeof(DWORD);
ret = RegQueryValueEx(m_hKey, L"BootCount", NULL, NULL,
(LPBYTE)&dwValue,
&dwLen);
ret = RegSetValueEx(m_hKey, L"Test", 0, REG_DWORD, (LPBYTE)&dwValue,
sizeof(DWORD));
ret = RegCloseKey(m_hKey);
ret = RegFlushKey(HKEY_LOCAL_MACHINE);
Sleep(1000);
wprintf(L"Exiting...\n");
return 0;
}
Here is the code that can be compliled successfully, but not run.
//CReg class RegHelper.h
#pragma once
/////////////////////////////////////////////////////////////////////////////
// CReg: Registry helper class
/////////////////////////////////////////////////////////////////////////////
#define MyFree(p) { if(p) LocalFree(p); }
class CReg
{
private:
HKEY m_hKey;
int m_Index;
LPBYTE m_lpbValue; // last value read, if any
public:
BOOL Create(HKEY hkRoot, LPCTSTR pszKey) {
DWORD dwDisp;
return ERROR_SUCCESS==RegCreateKeyEx(hkRoot, pszKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &m_hKey, &dwDisp);
}
BOOL Open(HKEY hkRoot, LPCTSTR pszKey, REGSAM sam=KEY_READ) {
return ERROR_SUCCESS==RegOpenKeyEx(hkRoot, pszKey, 0, sam, &m_hKey);
}
CReg(HKEY hkRoot, LPCTSTR pszKey) {
m_hKey = NULL;
m_Index = 0;
m_lpbValue = NULL;
Open(hkRoot, pszKey);
}
CReg() {
m_hKey = NULL;
m_Index = 0;
m_lpbValue = NULL;
}
~CReg() {
if(m_hKey) RegCloseKey(m_hKey);
MyFree(m_lpbValue);
}
void Reset() {
if(m_hKey) RegCloseKey(m_hKey);
MyFree(m_lpbValue);
m_hKey = NULL;
m_Index = 0;
m_lpbValue = NULL;
}
operator HKEY() { return m_hKey; }
BOOL IsOK(void) { return m_hKey!=NULL; }
BOOL EnumKey(LPTSTR psz, DWORD dwLen) {
if(!m_hKey) return FALSE;
return ERROR_SUCCESS==RegEnumKeyEx(m_hKey, m_Index++, psz, &dwLen,
NULL,
NULL, NULL, NULL);
}
BOOL EnumValue(LPTSTR pszName, DWORD dwLenName, LPTSTR pszValue, DWORD
dwLenValue) {
DWORD dwType;
if(!m_hKey) return FALSE;
dwLenValue *= sizeof(TCHAR); // convert length in chars to bytes
return ERROR_SUCCESS==RegEnumValue(m_hKey, m_Index++, pszName,
&dwLenName,
NULL, &dwType, (LPBYTE)pszValue, &dwLenValue);
}
BOOL ValueSZ(LPCTSTR szName, LPTSTR szValue, DWORD dwLen) {
if(!m_hKey) return FALSE;
dwLen *= sizeof(TCHAR); // convert length in chars to bytes
return ERROR_SUCCESS==RegQueryValueEx(m_hKey, szName, NULL, NULL,
(LPBYTE)szValue, &dwLen);
}
DWORD ValueBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen) {
if(!m_hKey) return FALSE;
DWORD dwLenWant = dwLen;
if(ERROR_SUCCESS==RegQueryValueEx(m_hKey, szName, NULL, NULL, lpbValue,
&dwLen))
return dwLen;
else
return 0;
}
LPCTSTR ValueSZ(LPCTSTR szName);
LPBYTE ValueBinary(LPCTSTR szName) {
return (LPBYTE)ValueSZ(szName);
}
DWORD ValueDW(LPCTSTR szName, DWORD dwDefault=0) {
if(!m_hKey) return FALSE;
DWORD dwValue = dwDefault;
DWORD dwLen = sizeof(DWORD);
RegQueryValueEx(m_hKey, szName, NULL, NULL, (LPBYTE)&dwValue, &dwLen);
return dwValue;
}
BOOL SetSZ(LPCTSTR szName, LPCTSTR szValue, DWORD dwLen) {
//Prefix
if(!m_hKey) return FALSE;
//
return ERROR_SUCCESS==RegSetValueEx(m_hKey, szName, 0, REG_SZ,
(LPBYTE)szValue, sizeof(TCHAR)*dwLen);
}
BOOL SetSZ(LPCTSTR szName, LPCTSTR szValue) {
return SetSZ(szName, szValue, 1+lstrlen(szValue));
}
BOOL SetDW(LPCTSTR szName, DWORD dwValue) {
//Prefix
if(!m_hKey) return FALSE;
//
return ERROR_SUCCESS==RegSetValueEx(m_hKey, szName, 0, REG_DWORD,
(LPBYTE)&dwValue, sizeof(DWORD));
}
BOOL SetBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen) {
//Prefix
if(!m_hKey) return FALSE;
//
return ERROR_SUCCESS==RegSetValueEx(m_hKey, szName, 0, REG_BINARY,
lpbValue, dwLen);
}
BOOL SetMultiSZ(LPCTSTR szName, LPCTSTR lpszValue, DWORD dwLen) {
return ERROR_SUCCESS==RegSetValueEx(m_hKey, szName, 0, REG_MULTI_SZ,
(LPBYTE)lpszValue, sizeof(TCHAR)*dwLen);
}
BOOL DeleteValue(LPCTSTR szName) {
//Prefix
if(!m_hKey) return FALSE;
//
return ERROR_SUCCESS==RegDeleteValue(m_hKey, szName);
}
BOOL DeleteKey(LPCTSTR szName) {
if(!m_hKey) return FALSE;
return ERROR_SUCCESS==RegDeleteKey(m_hKey, szName);
}
};
//CReg class
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
#include "RegHelper.h"
int _tmain(int argc, _TCHAR* argv[])
{
CReg reg;
reg.Open(HKEY_LOCAL_MACHINE, L"Comm");
DWORD dwCount = reg.ValueDW("BootCount", 0);
}
Any idea?
"Paul G. Tobey [eMVP]" wrote:
You'll have to show that code then. You're probably making them
instance
methods or something. There's no 'this' pointer passed to registry
calls...
Paul T.
"Long" <Long@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5207C64C-5E5A-4DF4-811A-D2DED88FE531@xxxxxxxxxxxxxxxx
It is a Smart Device project. It works well when I code it as C
style,
such
as calling the Registry APIs directly. But when I wrap those APIs
in a
class, it failed.
"Paul G. Tobey [eMVP]" wrote:
It would be something like you're building the application to
target
the
wrong processor type or something of that sort, not some sneaky
setting
buried five layers deep in the project properties. You *did* build
it
as
a
Smart Device project, not a desktop project, right? If it's a
desktop
EXE,
it's *not* a valid Windows CE executable.
Paul T.
"Long" <Long@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E3D1B65E-2C86-4755-AFFE-7921F1908B36@xxxxxxxxxxxxxxxx
Thanks Robert. That is what I am thinking the settings of VS2005
C++
may
be
the cause of my problem. There is no problem for the identity of
my
device,
Colibri PXA270, since the image I built with their BSP works
perfectly.
The
- Follow-Ups:
- Re: VS2005 compatibility
- From: Paul G. Tobey [eMVP]
- Re: VS2005 compatibility
- References:
- Re: VS2005 compatibility
- From: r_z_aret
- Re: VS2005 compatibility
- From: Long
- Re: VS2005 compatibility
- From: r_z_aret
- Re: VS2005 compatibility
- From: Long
- Re: VS2005 compatibility
- From: Paul G. Tobey [eMVP]
- Re: VS2005 compatibility
- From: Long
- Re: VS2005 compatibility
- From: Paul G. Tobey [eMVP]
- Re: VS2005 compatibility
- From: Long
- Re: VS2005 compatibility
- From: Paul G. Tobey [eMVP]
- Re: VS2005 compatibility
- From: Long
- Re: VS2005 compatibility
- From: Paul G. Tobey [eMVP]
- Re: VS2005 compatibility
- Prev by Date: Re: how to detect the windows manager is ready
- Next by Date: Re: VS2005 compatibility
- Previous by thread: Re: VS2005 compatibility
- Next by thread: Re: VS2005 compatibility
- Index(es):
Relevant Pages
|
Loading