FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Which version the latest of D2 support juno.051?
Goto page Previous  1, 2
 
Post new topic   Reply to topic     Forum Index -> Juno
View previous topic :: View next topic  
Author Message
samsam698



Joined: 10 Jan 2008
Posts: 63

PostPosted: Thu Dec 10, 2009 2:52 am    Post subject: Reply with quote

Numpsy wrote:


Try adding an import for juno.xml.msxml.


Thanks a lot.It works now.

I found automation examples (ie,word,excel),but none works fine:
Code:

module example;

import juno.com.core;
import std.stdio;

void testIE()
{
   auto ieApp=coCreate!(IDispatch)("InternetExplorer.Application");
   invokeMethod(ieApp,"Navigate","http://www.amazon.com");
}
void testWord()
{
   IDispatch wordApp=coCreate!(IDispatch)("Word.Application");
   IDispatch documents=getProperty!(IDispatch)(wordApp,"Documents");
   VARIANT count=getProperty(documents,"Count");
   writefln("There are %s documents",count);
}
void testExcel()
{
   IDispatch excelApp=coCreate!(IDispatch)("Excel.Application");
   setProperty(excelApp,"Visible",true);
   IDispatch workbooks=getProperty!(IDispatch)(excelApp,"Workbooks");
   IDispatch newWorkbook=invokeMethod!(IDispatch)(workbooks,"Add");
   IDispatch worksheet=getProperty!(IDispatch)(excelApp,"Worksheets",1);
   setProperty(worksheet,"Cells",5,3,"data");
}
void main()
{
   //testIE;
   //testWord;
   testExcel;
}


All three functions TestIE(),testWord() and testExcel() produce the same error:Error:Accesss Violation.
Back to top
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Thu Dec 10, 2009 8:53 am    Post subject: Reply with quote

Seems to be related to COM execution contexts. I don't remember how it all works offhand, but try changing the example code to:


Code:
IDispatch excelApp=coCreate!(IDispatch)("Excel.Application", ExecutionContext.LocalServer);
.
Back to top
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Thu Dec 10, 2009 2:41 pm    Post subject: Reply with quote

samsam698 wrote:


For pingServer,when program runs,it reported "Error:Operation is not valid";



Looks like the error is coming from the

return supportsIPv6_.value;

in the supportsIPv6() function juno/net/core.d , as supportsIPv6_ is not initialized if IPv6 is not supported.
Setting it to false if there is no support allows the sample to work. e.g.

Code:

if (GetLastError() != WSAEAFNOSUPPORT)
      supportsIPv6_ = true;
    else
      supportsIPv6_ = false;
Back to top
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Thu Dec 10, 2009 2:58 pm    Post subject: Reply with quote

samsam698 wrote:

For registry test function,it works fine except printing blank with the value of DWordValue/BinarayValue and MultiStringValue:


Seems that the

Code:

key.getValue!(string)(valueName)


always returns an empty string if the type of the key specified by 'valueName' is anything other than string.
You need to do something like getValue!(uint) or getValue!(string[]) to get the other types of value.
Back to top
View user's profile Send private message
samsam698



Joined: 10 Jan 2008
Posts: 63

PostPosted: Thu Dec 10, 2009 8:44 pm    Post subject: Reply with quote

Numpsy wrote:
Seems to be related to COM execution contexts. I don't remember how it all works offhand, but try changing the example code to:


Code:
IDispatch excelApp=coCreate!(IDispatch)("Excel.Application", ExecutionContext.LocalServer);
.


Under your great help.I have solved all the problem.Really ...thanks!

Just one question,I tried to set ExecutionContext to InProcess/InProcesHandler/LocalServer/All but nothing happend to my
testIE() function which try to load amazon webpage.

Was I missing something?
Back to top
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Sat Dec 12, 2009 8:40 am    Post subject: Reply with quote

samsam698 wrote:


Just one question,I tried to set ExecutionContext to InProcess/InProcesHandler/LocalServer/All but nothing happend to my
testIE() function which try to load amazon webpage.



When i try it with LocalServer, it creates an instance of IE ok, but it's invisible.
Adding a

Code:

setProperty(ieApp, "Visible", VARIANT_TRUE);


Before calling navigate makes the window visible.
Back to top
View user's profile Send private message
samsam698



Joined: 10 Jan 2008
Posts: 63

PostPosted: Mon Dec 14, 2009 8:57 pm    Post subject: Reply with quote

Numpsy wrote:


When i try it with LocalServer, it creates an instance of IE ok, but it's invisible.
Adding a

Code:

setProperty(ieApp, "Visible", VARIANT_TRUE);


Before calling navigate makes the window visible.


Thanks.

Three more questions:P
1.crypto and file monitoring sample:
Code:


module exjunofileio;

import std.base64;
import juno.base.text;
import juno.security.crypto;
import juno.io.filesystem;
import std.stdio;
import std.c.stdio;
import std.c.stdlib;

void encrptWord()
{
   string text="some text to be hashed.";
   ubyte[] textBytes=Encoding.UTF8.encode(text);
   
   scope md5=new Md5CryptoServiceProvider;
   ubyte[] hashedBytes=md5.computeHash(textBytes);
   
   string hashedText=std.base64.encode(cast(char[])hashedBytes);
   writefln(hashedText);
}


void fileMonitor()
{
   scope watcher=new Watcher;
   watcher.path="f:\\";
   
   watcher.created+=(Object,FileSystemEventArgs e)
   {
      writefln("File %s created\n",e.fullPath);
      //fflush(stdout);
      
   };
   watcher.deleted+=(Object,FileSystemEventArgs e)
   {
      writefln("File %s deleted\n",e.fullPath);
      //fflush(stdout);
   };
   watcher.changed+=(Object,FileSystemEventArgs e)
   {
      writefln("File %s changed\n",e.fullPath);
      //fflush(stdout);
   };
   watcher.renamed+=(Object,RenamedEventArgs e)
   {
      writefln("File %s renamed to %s\n",e.oldFullPath,e.fullPath);
      //fflush(stdout);
   };
   watcher.enableEvents=true;
   writefln("Press 'q' to quit\n");
   //fflush(stdout);
   while(std.c.stdio.getch()!='q')
   {
      //leave blank here to entering listening loop...
   }
   
}

void main()
{
   
   fileMonitor;
   encrptWord;
}


The file monitor function works strange.It can only monitor files exist in the root of F: driver,it does not make sense to the sub folder;During the program execution,(filemonitor() working...),when I change the active window to and back between F:\ and its subfolder,the program stop working.Is this the expected result?

Adding encrpty module and the 'void encrptWord()' function,the program can not get compiled:


F:\DLang\DEx\D1Ex>bud -O -release -clean juno.lib exjunofileio.d
OPTLINK (R) for Win32 Release 8.00.2
Copyright (C) Digital Mars 1989-2009 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
F:\DLang\DTwo\dmd\windows\include\d\juno\security\crypto.obj(crypto)
Error 42: Symbol Undefined _CryptFindOIDInfo@12
F:\DLang\DTwo\dmd\windows\include\d\juno\security\crypto.obj(crypto)
Error 42: Symbol Undefined _CryptProtectData@28
F:\DLang\DTwo\dmd\windows\include\d\juno\security\crypto.obj(crypto)
Error 42: Symbol Undefined _CryptUnprotectData@28

F:\DLang\DEx\D1Ex>

What's wrong here?

One last question,do you get your copy of juno built under DMD2.037+ or D1/Tango?If yes,could you please share?

Thanks and best regards,
Sam
Back to top
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Wed Dec 16, 2009 6:43 am    Post subject: Reply with quote

samsam698 wrote:

F:\DLang\DTwo\dmd\windows\include\d\juno\security\crypto.obj(crypto)
Error 42: Symbol Undefined _CryptFindOIDInfo@12
F:\DLang\DTwo\dmd\windows\include\d\juno\security\crypto.obj(crypto)
Error 42: Symbol Undefined _CryptProtectData@28
F:\DLang\DTwo\dmd\windows\include\d\juno\security\crypto.obj(crypto)
Error 42: Symbol Undefined _CryptUnprotectData@28


I guess that you need to link with crypt32.lib (which alas isn't distributed with DMD).

samsam698 wrote:

One last question,do you get your copy of juno built under DMD2.037+


I tried to build it, but ran into several issues. Theres some discussion about the problems @ :

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=18405

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=103410
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Juno All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group