473,320 Members | 1,952 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.

Check Compact Framework version in registry

Here is some code that is not working right for me. This is designed to run on Compact Framework 1, so I cannot just use the registry classes. Obviously GetInstalledVersions() is incomplete as far as what it is returning , but the part that I can't figure out is the call to RegQueryValueEx, which returns a value of 2 instead 0. I already tried passing in an array of bytes instead of the StringBuilder but this did not fix it. The device I am testing this code on does have a registry entry here. I looked it up using a registry viewer. Any ideas?

Expand|Select|Wrap|Line Numbers
  1. public class CompactFrameworkVersionChecker
  2.  
  3. {
  4. private const uint HKEY_LOCAL_MACHINE = 0x80000002;
  5.  
  6. [DllImport("coredll.dll", CharSet=CharSet.Unicode)]
  7. private static extern uint RegOpenKeyEx(
  8. uint HKEY,
  9. string lpSubKey,
  10. int ulOptions,
  11. uint samDesired,
  12. out uint phkResult);
  13.  
  14. [DllImport("coredll.dll", CharSet=CharSet.Unicode)]
  15. private static extern uint RegQueryValueEx(
  16. uint hKey,
  17. string lpValueName,
  18. int lpReserved,
  19. ref int lpType,
  20. StringBuilder lpData,
  21. ref int lpcbData);
  22.  
  23. [DllImport("coredll.dll")]
  24. private static extern int RegCloseKey(uint hkey);
  25.  
  26. public static string[] GetInstalledVersions()
  27. {
  28. uint key;
  29. uint ret;
  30.  
  31. int lpType = new int();
  32. StringBuilder lpData = new StringBuilder();
  33. int lpcbData = lpData.Length;
  34. ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft", 0, 0, out key);
  35. string[] installedVersions = new string[] { };
  36. if (ret == 0)
  37. {
  38. ret = RegQueryValueEx(key, ".NETCompactFramework", 0, ref lpType, lpData, ref lpcbData);
  39. if (ret == 0)
  40. {
  41. // success, your data in in lpData to be converted
  42. installedVersions = new string[] { lpData.ToString() };
  43. }
  44. }
  45. RegCloseKey(key);
  46. return installedVersions;
  47. }
  48. }
  49.  
Jan 28 '08 #1
3 4479
Plater
7,872 Expert 4TB
You are using a compact framework app to check the version of compact framework?
Jan 29 '08 #2
r035198x
13,262 8TB
... This is designed to run on Compact Framework 1...s
Shouldn't the program just give Compact Framework 1 as the answer then?
Jan 29 '08 #3
Plater
7,872 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. \windows\cgacutil.exe
  2.  
That command pops up a window to tell you what version of CF you have running. Although it requires that you not be headless, and it doesn't help you at runtime.
Jan 29 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Duncan | last post by:
I am using the evaluation version of CE.NET 4.1. I had also installed the release version of the Compact Framework. I uninstalled the CE.NET 4.1, and then realized I needed it again and...
1
by: Asad Khan | last post by:
Hi, I have Visual Studio 2002 Enterprise Architecture Edition. I was wondering if anyone has any information on how I can develop applications for .Net Compact Framework using this IDE. I've heard...
2
by: paul | last post by:
I have developed an application for pocket pc that requires multiple forms to be open at any one time. The user is able to flick from one to the other, making changes to each as and when necessary...
2
by: j.b.messina | last post by:
This has not yet been published by Microsoft. It will be published within the next few weeks, mainly because I asked them to. I felt this was information badly needed, and I think this is the...
4
by: André Giesing | last post by:
Hello NG! I've got a short question: Is there a difference of the internal representation of a Hashtable between the Compact Framework and the normal Framework? I've got the suspicion,...
2
by: Hans Kesting | last post by:
Is it possible to mix code meant for the CompactFramework and code meant for the standard framework? We are trying to make PDA and light-weight "laptop" versions of one application. This means a...
2
by: Jak Sparrow | last post by:
What are some good ways to programmatically check for software already installed on a computer? For example, to check a version of Internet Explorer, a program can check the registry for the...
11
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. Is there a way to programmatically check for .NET Framework versions installed on the computer? -- Michael Bragg,...
13
by: dancer | last post by:
I have made a new post because when I try to respond to another, I get the error, "Article Rejected -- Ill-formed message id" This is in response to the advice of Juan Libre to install Net...
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: 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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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....

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.