473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

unsupported function problem - WinCE

Hello all,

I'm trying to run a small program on both PPC and CE devices.
I am calling SHGetAutoRunPath only when running on a PPC platform.
However, since this function depends on aygshell.dl, which doesn't
exist on the CE platform, the program does not run at all on the CE
platform.
if(lstrcmpi(lpCmdLine, _T("install")) == 0)
{
// Card has been inserted. We NEVER get here on a CE platform!

TCHAR szSDAutorunFullPath[MAX_PATH+1]; // Compact Flash path
SHGetAutoRunPath(szSDAutorunFullPath);
......
}

Is there a way to make the program run on both platforms without
recompiling it?

Thanks a lot,

Yoav.
Oct 2 '08 #1
5 2270
yoavrofe wrote:
I'm trying to run a small program on both PPC and CE devices.
I am calling SHGetAutoRunPath only when running on a PPC platform.
However, since this function depends on aygshell.dl, which doesn't
exist on the CE platform, the program does not run at all on the CE
platform.
if(lstrcmpi(lpCmdLine, _T("install")) == 0)
{
// Card has been inserted. We NEVER get here on a CE platform!

TCHAR szSDAutorunFullPath[MAX_PATH+1]; // Compact Flash path
SHGetAutoRunPath(szSDAutorunFullPath);
.....
}

Is there a way to make the program run on both platforms without
recompiling it?
C++ language Standard defines the language so that the portability
requirement is satisfied on the *source code* level, not on the binary
level. No other guarantees exist from the platform point of view WRT
the executables you can produce from that code. Now, if your platform
chooses to give you some additional guarantees, e.g. that the executable
can run on two platforms if built with certain settings, then it's the
choice of the *platform*, not the language. IOW, you need to ask about
those things in the *platform* newsgroup, not the language newsgroup.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 2 '08 #2
Thanks, Victor.

What I wanted to ask is if it's possible to declare the function only
when I intend to use it.
Oct 2 '08 #3
yoavrofe wrote:
What I wanted to ask is if it's possible to declare the function only
when I intend to use it.
What's "intend to use it" mean. What would be the point of declaring it
if you don't intend to use it?

I am reaching here, but have you heard of "conditional compilation"? I
mean the #ifdef or #if blocks... It's not going to solve your "no
recompilation to run on the other OS" problem, though.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 2 '08 #4
yoavrofe wrote:
Hello all,

I'm trying to run a small program on both PPC and CE devices.
I am calling SHGetAutoRunPath only when running on a PPC platform.
However, since this function depends on aygshell.dl, which doesn't
exist on the CE platform, the program does not run at all on the CE
platform.
if(lstrcmpi(lpCmdLine, _T("install")) == 0)
{
// Card has been inserted. We NEVER get here on a CE platform!

TCHAR szSDAutorunFullPath[MAX_PATH+1]; // Compact Flash path
SHGetAutoRunPath(szSDAutorunFullPath);
.....
}

Is there a way to make the program run on both platforms without
recompiling it?
Define a semantically abstract interface to represent the underlying
platform. Implement this interface separately for each platform you
support, defining each such implementation in a separate source code module.

Your main routine, the client of the platform access modules, should
access the platform only through the abstract interface. Your build
system can then select the correct, platform-specific implementation to
link into your application for each build target. If you find there is
a lot of common code among the platform-specific modules, factor it into
a separate "platform support" module.

IOW, your driver routine probably shouldn't be calling something like
SHSomeHorridLookingFunctionName directly, anyway. Instead, it should be
calling platform.cardInserted, where "platform" is of a type defined by
the build system. If you want to stick with the C-like coding style
above, you might just declare:

void platformCardInserted();

Multiple compiled object modules can define platformCardInserted, as
long as the build system links exactly one into your application for any
given build target.

Victor suggested #ifdef'ing out the platform-specific line. If it
really is just a very small amount of platform-specific code, that may
be the best thing to do; however: (1) it still requires target-specific
behavior in the build system, to pass -DPLATFORM=WHATEVER, and (2) as
Victor pointed out, it requires a separate compilation, rather than a
separate link, for each platform.
Oct 2 '08 #5
First, this belongs more in comp.os.ms-windows.programmer.win32

Next, the function is declared:

BOOL WINAPI SHGetAutoRunPath(LPTSTR pAutoRunPath);

Which is a normal C declration. So, to make life easy, first we make a function pointer typedef. How to do that is more c/c++ than win32. And we declare an instance of that new type and initialize it.

typedef BOOL(WINAPI* PFNSHGETAUTORUNPATH)(LPTSTR);
PFNSHGETAUTORUNPATH pSHGetAutoRunPath = NULL;

Now, the win32 part. We load the function pointer from the relevent platform dll.

HMODULE hAygShell = LoadLibrary(TEXT("aygshell.dll"));
pSHGetAutoRunPath = (PFNSHGETAUTORUNPATH) GetProcAddress(hAygShell,"SHGetAutoRunPathW");

Now, you can test pSHGetAutoRunPath to see if it was loaded or not before calling it with code similar to this:-

TCHAR szBuf[MAX_PATH]={0};
if(pSHGetAutoRunPath) {
pSHGetAutoRunPath(szBuf);
} else {
// fake it on platforms that dont have it.
}

One last note: "SHGetAutoRunPathW" has the W on the end because most win32 functions exist in W or A suffix versions which are used when you build for Unicode or Ansi support. Because the platform in question might be unicode only, the W might not be necessary. If the GetProcAddress call fails on the platform it should succeed on, try the other variations.
Oct 3 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: DJ Craig | last post by:
I keep getting this error: Fatal error: Unsupported operand types in /usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.php on line 58 I've looked for hours for some type of error, and...
0
by: //\\//\\RLe | last post by:
We are testing one of the CASIO hand device on WinCE and wireless module... while trying to run any Oracle Forms in web browser found that we need JavaInitiator for WinCE and... can't find any on...
10
by: Vavel | last post by:
Hi all! I want to insert the record into the table by using an application program that includes the following statements: EXEC SQL BEGIN DECLARE SECTION; long hvInt_Stor; long hvExt_Stor;...
1
by: Beyers | last post by:
Hi We are using active sync to connect VS.NET to a WinCE hardware platform for debuggging the application we are writing for this platform. It worked well for a month, and now all of a sudden...
2
by: parth_mca | last post by:
i want to start WinCE programming in vb.net... which version of visual studio.net supports winCE programming for PocketPC ? and where should i start from...?
2
by: bokiteam | last post by:
Hi All, I am developing a WinCE project, when I include datagrid, it says no define.. could you please advice? it works on Win32 project by the same code... Thank you very much for you...
3
by: pcm | last post by:
Hi, Has anyone ever worked on a Python-WinCE-based program that involved serial port management ? Regards, Philippe
1
by: TheSebaster | last post by:
I wrote the following lines of code under Microsoft Visual Studio 2005: I compile my WinCE c++ application importing MyInterop.tlb generated file. The MyInterop.tlh generated file do not contain my...
2
by: clintonG | last post by:
Okay I'm lazy (today) and asking without doing a lot of searching for the moment but does the framework run on a device using WinCE and can IIS run on that same device perchance? Finally will WPF...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.