www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D1: Passing 0x00000000 value to a Windows COM function

reply jicman <cabrera_ _wrc.xerox.com> writes:
Greetings.

I am trying to pass a (I think) dchar value to a Windows COM
function and it does not work.  Imagine this situation...

dchar test()
{
  dchar val = 0x00000000;
  return val
}

void main()
{
  ...lots of code excluded
  SomeWindowsComCall(test); // this call does not work
  SomeWindowsComCall(0x00000000); // this call works
}

Any idea how I can create a function to be able to return values
such as 0x00000000 .. 0x0000FFFF?

Thanks.

josÚ
Aug 19 2012
next sibling parent reply torhu <no spam.invalid> writes:
On 20.08.2012 00:43, jicman wrote:
 Greetings.

 I am trying to pass a (I think) dchar value to a Windows COM
 function and it does not work.  Imagine this situation...

 dchar test()
 {
    dchar val = 0x00000000;
    return val
 }

 void main()
 {
    ...lots of code excluded
    SomeWindowsComCall(test); // this call does not work
    SomeWindowsComCall(0x00000000); // this call works
 }

 Any idea how I can create a function to be able to return values
 such as 0x00000000 .. 0x0000FFFF?

It's easier to help if you post an actual, compilable example. As small as possible. Because the code you posted doesn't show any real possibility of bugs, barring compiler bugs.
Aug 20 2012
parent reply jicman <cabrera_ _wrc.xerox.com> writes:
== Quote from torhu (no spam.invalid)'s article
 On 20.08.2012 00:43, jicman wrote:
 Greetings.

 I am trying to pass a (I think) dchar value to a Windows COM
 function and it does not work.  Imagine this situation...

 dchar test()
 {
    dchar val = 0x00000000;
    return val
 }

 void main()
 {
    ...lots of code excluded
    SomeWindowsComCall(test); // this call does not work
    SomeWindowsComCall(0x00000000); // this call works
 }

 Any idea how I can create a function to be able to return values
 such as 0x00000000 .. 0x0000FFFF?


 as possible. Because the code you posted doesn't show any real
 possibility of bugs, barring compiler bugs.

Hi Torhu. Thanks for the reply, but this is an old and working setup using the Juno project. So, you'll need to install the Juno project, http://dsource.org/projects/juno and the Trados 2007 Translation software which I am pretty sure you won't because it is very expensive. :-) The sample provide is simple and it has no bug. Don-t forget that I said that I am passing that value to a Windows COM call using Juno, but I think that the returning value from the test function is not really returning 0x00000000 to the COM call. This is the actual subroutine that returns the value, dchar GetSourceLanguageEnumaration(char[] lang) { // *** STaggerF.SourceLanguage Enumeration *** dchar sl = 0x00000000; lang = std.string.tolower(lang); //msgBox(lang); switch(lang) { case "sq", "sq-al": // stfTargetLanguageAlbanian = 0x00000000, sl = 0x00000000; break; case "eu", "eu-es": // stfTargetLanguageBasque = 0x00000001, sl = 0x00000001; break; case "bg", "bg-bg": // stfTargetLanguageBulgarian = 0x00000002, sl = 0x00000002; break; case "be", "be-by": // stfTargetLanguageByelorussian = 0x00000003, sl = 0x00000003; break; case "ca", "ca-es": // stfTargetLanguageCatalan = 0x00000004, sl = 0x00000004; break; case "zh-cn": //= 5; //stfTargetLanguageChineseSimplified sl = 0x00000005; break; case "zh-tw": // = 6; //stfTargetLanguageChineseTraditional sl = 0x00000006; break; case "nl", "nl-nl": //stfTargetLanguageDutch = 0x0000000A, sl = 0x0000000A; break; case "en-gb": // stfTargetLanguageEnglishUk = 0x0000000B, sl = 0x0000000B; break; case "en", "en-us": // stfTargetLanguageEnglishUs = 0x0000000C, sl = 0x0000000C; break; case "fr", "fr-fr": // stfTargetLanguageFrench = 0x00000010, sl = 0x00000010; break; case "fr-ca": // stfTargetLanguageFrenchCanadian = 0x00000011, sl = 0x00000011; break; case "de", "de-de": // stfTargetLanguageGerman = 0x00000012, sl = 0x00000012; break; case "el", "el-gr": // stfTargetLanguageGreek = 0x00000014, sl = 0x00000014; break; case "it", "it-it": // stfTargetLanguageItalian = 0x00000017, sl = 0x00000017; break; case "ja", "ja-jp": // stfTargetLanguageJapanese = 0x00000018, sl = 0x00000018; break; case "ko", "ko-kr": // stfTargetLanguageKorean = 0x00000019, sl = 0x00000019; break; case "pl", "pl-pl": // stfTargetLanguagePolish = 0x0000001F, sl = 0x0000001F; break; case "pt", "pt-pt": // stfTargetLanguagePortuguese = 0x00000020, sl = 0x00000020; break; case "pt-br": // stfTargetLanguagePortugueseBrazilian = 0x00000021, sl = 0x00000021; break; case "ru", "ru-ru": // stfTargetLanguageRussian = 0x00000023, sl = 0x00000023; break; case "es", "es-es", "es-em", "es-la": // stfTargetLanguageSpanish = 0x00000027, sl = 0x00000027; break; case "tr", "tr-tr": // stfTargetLanguageTurkish = 0x00000029, sl = 0x00000029; break; /+ case "", "": sl = 12; break; enum SourceLanguage { stfSourceLanguageCroatian = 0x00000007, stfSourceLanguageCzech = 0x00000008, stfSourceLanguageDanish = 0x00000009, stfSourceLanguageEstonian = 0x0000000D, stfSourceLanguageFaeroese = 0x0000000E, stfSourceLanguageFinnish = 0x0000000F, stfSourceLanguageGermanSwiss = 0x00000013, stfSourceLanguageHungarian = 0x00000015, stfSourceLanguageIcelandic = 0x00000016, stfSourceLanguageLatvian = 0x0000001A, stfSourceLanguageLithuanian = 0x0000001B, stfSourceLanguageNone = 0x0000001C, stfSourceLanguageNorwegian = 0x0000001D, stfSourceLanguageNorwegianNynorsk = 0x0000001E, stfSourceLanguagePolish = 0x0000001F, stfSourceLanguagePortuguese = 0x00000020, stfSourceLanguagePortugueseBrazilian = 0x00000021, stfSourceLanguageRomanian = 0x00000022, stfSourceLanguageRussian = 0x00000023, stfSourceLanguageSerbian = 0x00000024, stfSourceLanguageSlovak = 0x00000025, stfSourceLanguageSlovenian = 0x00000026, stfSourceLanguageSpanish = 0x00000027, stfSourceLanguageSwedish = 0x00000028, stfSourceLanguageTurkish = 0x00000029, stfSourceLanguageUkrainian = 0x0000002A, stfSourceLanguageJapaneseWinAlign = 0x0000002B, stfSourceLanguageDutchNew = 0x0000002C, stfSourceLanguageGermanNew = 0x0000002D, stfSourceLanguageGermanSwissNew = 0x0000002E, } +/ default: sl = 0x0000000C; // stfSourceLanguageEnglishUs = 0x0000000C, break; } //return cast(dchar)sl; return sl; } Can someone that knows about the inside of D1 tells me if I am wrong or not? Thanks again. josÚ
Aug 20 2012
next sibling parent jicman <cabrera_ _wrc.xerox.com> writes:
== Quote from jicman (cabrera_ _wrc.xerox.com)'s article
 == Quote from torhu (no spam.invalid)'s article
 On 20.08.2012 00:43, jicman wrote:
 Greetings.

 I am trying to pass a (I think) dchar value to a Windows COM
 function and it does not work.  Imagine this situation...

 dchar test()
 {
    dchar val = 0x00000000;
    return val
 }

 void main()
 {
    ...lots of code excluded
    SomeWindowsComCall(test); // this call does not work
    SomeWindowsComCall(0x00000000); // this call works
 }

 Any idea how I can create a function to be able to return



 such as 0x00000000 .. 0x0000FFFF?



 small
 as possible. Because the code you posted doesn't show any real
 possibility of bugs, barring compiler bugs.


 using the Juno project.  So, you'll need to install the Juno

 http://dsource.org/projects/juno
 and the Trados 2007 Translation software which I am pretty sure you
 won't because it is very expensive. :-)  The sample provide is

 and it has no bug.  Don-t forget that I said that I am passing that
 value to a Windows COM call using Juno, but I think that the
 returning value from the test function is not really returning
 0x00000000 to the COM call.  This is the actual subroutine that
 returns the value,
 dchar GetSourceLanguageEnumaration(char[] lang)
 {
  //     *** STaggerF.SourceLanguage Enumeration ***
   dchar sl = 0x00000000;
   lang = std.string.tolower(lang);
   //msgBox(lang);
   switch(lang)
   {
     case "sq", "sq-al": // stfTargetLanguageAlbanian = 0x00000000,
       sl = 0x00000000;
     break;
     case "eu", "eu-es": // stfTargetLanguageBasque = 0x00000001,
       sl = 0x00000001;
     break;
     case "bg", "bg-bg": // stfTargetLanguageBulgarian = 0x00000002,
       sl = 0x00000002;
     break;
     case "be", "be-by": // stfTargetLanguageByelorussian =
 0x00000003,
       sl = 0x00000003;
     break;
     case "ca", "ca-es": // stfTargetLanguageCatalan = 0x00000004,
       sl = 0x00000004;
     break;
     case "zh-cn": //= 5; //stfTargetLanguageChineseSimplified
       sl = 0x00000005;
     break;
     case "zh-tw": // = 6; //stfTargetLanguageChineseTraditional
       sl = 0x00000006;
     break;
     case "nl", "nl-nl": //stfTargetLanguageDutch = 0x0000000A,
       sl = 0x0000000A;
     break;
     case "en-gb": // stfTargetLanguageEnglishUk = 0x0000000B,
       sl = 0x0000000B;
     break;
     case "en", "en-us": // stfTargetLanguageEnglishUs = 0x0000000C,
       sl = 0x0000000C;
     break;
     case "fr", "fr-fr": // stfTargetLanguageFrench = 0x00000010,
       sl = 0x00000010;
     break;
     case "fr-ca": // stfTargetLanguageFrenchCanadian = 0x00000011,
       sl = 0x00000011;
     break;
     case "de", "de-de": // stfTargetLanguageGerman = 0x00000012,
       sl = 0x00000012;
     break;
     case "el", "el-gr":  // stfTargetLanguageGreek = 0x00000014,
       sl = 0x00000014;
     break;
     case "it", "it-it": // stfTargetLanguageItalian = 0x00000017,
       sl = 0x00000017;
     break;
     case "ja", "ja-jp": // stfTargetLanguageJapanese = 0x00000018,
       sl = 0x00000018;
     break;
     case "ko", "ko-kr": // stfTargetLanguageKorean = 0x00000019,
       sl = 0x00000019;
     break;
     case "pl", "pl-pl": // stfTargetLanguagePolish = 0x0000001F,
       sl = 0x0000001F;
     break;
     case "pt", "pt-pt": // stfTargetLanguagePortuguese =

       sl = 0x00000020;
     break;
     case "pt-br": // stfTargetLanguagePortugueseBrazilian =
 0x00000021,
       sl = 0x00000021;
     break;
     case "ru", "ru-ru": // stfTargetLanguageRussian = 0x00000023,
       sl = 0x00000023;
     break;
     case "es", "es-es", "es-em", "es-la": //

 = 0x00000027,
       sl = 0x00000027;
     break;
     case "tr", "tr-tr": // stfTargetLanguageTurkish = 0x00000029,
       sl = 0x00000029;
     break;
     /+
     case "", "":
       sl = 12;
     break;
 enum SourceLanguage {
   stfSourceLanguageCroatian = 0x00000007,
   stfSourceLanguageCzech = 0x00000008,
   stfSourceLanguageDanish = 0x00000009,
   stfSourceLanguageEstonian = 0x0000000D,
   stfSourceLanguageFaeroese = 0x0000000E,
   stfSourceLanguageFinnish = 0x0000000F,
   stfSourceLanguageGermanSwiss = 0x00000013,
   stfSourceLanguageHungarian = 0x00000015,
   stfSourceLanguageIcelandic = 0x00000016,
   stfSourceLanguageLatvian = 0x0000001A,
   stfSourceLanguageLithuanian = 0x0000001B,
   stfSourceLanguageNone = 0x0000001C,
   stfSourceLanguageNorwegian = 0x0000001D,
   stfSourceLanguageNorwegianNynorsk = 0x0000001E,
   stfSourceLanguagePolish = 0x0000001F,
   stfSourceLanguagePortuguese = 0x00000020,
   stfSourceLanguagePortugueseBrazilian = 0x00000021,
   stfSourceLanguageRomanian = 0x00000022,
   stfSourceLanguageRussian = 0x00000023,
   stfSourceLanguageSerbian = 0x00000024,
   stfSourceLanguageSlovak = 0x00000025,
   stfSourceLanguageSlovenian = 0x00000026,
   stfSourceLanguageSpanish = 0x00000027,
   stfSourceLanguageSwedish = 0x00000028,
   stfSourceLanguageTurkish = 0x00000029,
   stfSourceLanguageUkrainian = 0x0000002A,
   stfSourceLanguageJapaneseWinAlign = 0x0000002B,
   stfSourceLanguageDutchNew = 0x0000002C,
   stfSourceLanguageGermanNew = 0x0000002D,
   stfSourceLanguageGermanSwissNew = 0x0000002E,
 }
     +/
     default:
       sl = 0x0000000C;
       // stfSourceLanguageEnglishUs = 0x0000000C,
     break;
   }
   //return cast(dchar)sl;
   return sl;
 }
 Can someone that knows about the inside of D1 tells me if I am

 or not?  Thanks again.

I guess there are no takers. :-) Ok, I will pose some questions: 1. what type of value is this: 0x00000001? (I thought it was a dchar type, but returning that value as dchar does not work) 2. How can I create a function that would return values such as these? (0x00000000, 0x0000000A, 0x00000000,..., etc.) thanks for your help. jic
Aug 20 2012
prev sibling parent torhu <no spam.invalid> writes:
On 20.08.2012 18:22, jicman wrote:
...
 dchar GetSourceLanguageEnumaration(char[] lang)
 {
   //     *** STaggerF.SourceLanguage Enumeration ***
    dchar sl = 0x00000000;
    lang = std.string.tolower(lang);
    //msgBox(lang);
    switch(lang)
    {
      case "sq", "sq-al": // stfTargetLanguageAlbanian = 0x00000000,

I don't think that will work, try this instead: case "sq": case "sq-al":
Aug 21 2012
prev sibling next sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 08/19/2012 03:43 PM, jicman wrote:
 Greetings.

 I am trying to pass a (I think) dchar value to a Windows COM
 function and it does not work.  Imagine this situation...

 dchar test()
 {
    dchar val = 0x00000000;
    return val
 }

 void main()
 {
    ...lots of code excluded
    SomeWindowsComCall(test); // this call does not work
    SomeWindowsComCall(0x00000000); // this call works
 }

 Any idea how I can create a function to be able to return values
 such as 0x00000000 .. 0x0000FFFF?

 Thanks.

 jos´┐Ż

How about using dchar literals: http://digitalmars.com/d/1.0/expression.html#CharacterLiteral dchar test() { return '\U00000000'; } Ali
Aug 20 2012
prev sibling parent torhu <no spam.invalid> writes:
On 20.08.2012 00:43, jicman wrote:
 Greetings.

 I am trying to pass a (I think) dchar value to a Windows COM
 function and it does not work.  Imagine this situation...

 dchar test()
 {
    dchar val = 0x00000000;
    return val
 }

 void main()
 {
    ...lots of code excluded
    SomeWindowsComCall(test); // this call does not work
    SomeWindowsComCall(0x00000000); // this call works
 }

 Any idea how I can create a function to be able to return values
 such as 0x00000000 .. 0x0000FFFF?

Returning a dchar works just fine when I try it, there is probably a bug in your code. What is the argument type of SomeWindowsComCall? That's the type you should, and it's probably not a dchar. Look at the MSDN docs for the function to see what type it wants.
Aug 21 2012