Archive for June, 2008
article source : http://www.delphi3000.com/articles/article_525.asp?SK=
author : Igor Siticov
For creating file associations you should make some registry changes and inform Windows explorer about your changes.
For launching your program as default for all unregistered file types just associate it for “*” file type.
The following unit includes realization of function for creating file association.
See comments in source for details.
-
-
unit utils;
-
-
interface
-
uses Registry, ShlObj, SysUtils, Windows;
-
-
procedure RegisterFileType(cMyExt, cMyFileType, cMyDescription, ExeName: string; IcoIndex: integer; DoUpdate: boolean = false);
-
-
implementation
-
-
procedure RegisterFileType(cMyExt, cMyFileType, cMyDescription, ExeName: string; IcoIndex: integer; DoUpdate: boolean = false);
-
var
-
Reg: TRegistry;
-
begin
-
Reg := TRegistry.Create;
-
try
-
Reg.RootKey := HKEY_CLASSES_ROOT;
-
Reg.OpenKey(cMyExt, True);
-
// Write my file type to it.
-
// This adds HKEY_CLASSES_ROOT\.abc\(Default) = ‘Project1.FileType’
-
Reg.WriteString(”, cMyFileType);
-
Reg.CloseKey;
-
// Now create an association for that file type
-
Reg.OpenKey(cMyFileType, True);
-
// This adds HKEY_CLASSES_ROOT\Project1.FileType\(Default)
-
// = ‘Project1 File’
-
// This is what you see in the file type description for
-
// the a file’s properties.
-
Reg.WriteString(”, cMyDescription);
-
Reg.CloseKey; // Now write the default icon for my file type
-
// This adds HKEY_CLASSES_ROOT\Project1.FileType\DefaultIcon
-
// \(Default) = ‘Application Dir\Project1.exe,0′
-
Reg.OpenKey(cMyFileType + ‘\DefaultIcon’, True);
-
Reg.WriteString(”, ExeName + ‘,’ + IntToStr(IcoIndex));
-
Reg.CloseKey;
-
// Now write the open action in explorer
-
Reg.OpenKey(cMyFileType + ‘\Shell\Open’, True);
-
Reg.WriteString(”, ‘&Open’);
-
Reg.CloseKey;
-
// Write what application to open it with
-
// This adds HKEY_CLASSES_ROOT\Project1.FileType\Shell\Open\Command
-
// (Default) = ‘"Application Dir\Project1.exe" "%1"’
-
// Your application must scan the command line parameters
-
// to see what file was passed to it.
-
Reg.OpenKey(cMyFileType + ‘\Shell\Open\Command’, True);
-
Reg.WriteString(”, ‘"’ + ExeName + ‘" "%1"’);
-
Reg.CloseKey;
-
// Finally, we want the Windows Explorer to realize we added
-
// our file type by using the SHChangeNotify API.
-
if DoUpdate then SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
-
finally
-
Reg.Free;
-
end;
-
end;
-
-
end.
-
Today i found some great post to make an integration between JAVA and static library genetated with C++ using JNI.
post links :
stay tuned
ivan…
In this article we see how can we deploy a web service, you need to have apache, tomcat and axis up and running.
To publish a simple webservice:
Create a simple text file, for example “Somma.jws” like this
-
public class Somma {
-
public int somma(int a, int b) {
-
return a+b;
-
}
-
}
Put this file in the axis directory, for example: /usr/local/apache-tomcat-6.0.13/webapps/axis
the web service is already available at: http://localhost:8080/axis/Somma.jws
the WSDL: http://localhost:8080/axis/Somma.jws?wsdl
direct invocation via query string: http://localhost:8080/axis/Somma.jws?method=somma&a=2&b=3
This is a very interesting feature, you can call the web service via simple web request, for example via javascript, without the complicated stuff needed for invoking a web service .
The jws web service is simple and fast, but they support only standard type String, int and so on.
For a more complex web service you have to deploy it from the java source code, and a wsdd (Web Service Deployment Descriptor) text file:
Example:
-
package com.server;
-
public class Company {
-
public int companyID;
-
public String companyName;
-
}
-
package com.server;
-
public class CompanyService{
-
-
/**
-
* @return company object
-
*/
-
public Company getCompanyData(){
-
Company company = new Company();
-
company.companyID = 2311;
-
company.companyName = "Test";
-
company.employeeNames = employeeNames;
-
return company;
-
}
-
}
-
<deployment xmlns="http://xml.apache.org/axis/wsdd/">
-
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
-
xmlns:myNS="http://www.synaptica.info" >
-
<service name="CompanyRepository" provider="java:RPC"></service></deployment>
-
<parameter name="className" value="com.server.CompanyService"></parameter>
-
<parameter name="allowedMethods" value="getCompanyData"></parameter>
-
<parameter name="wsdlTargetNamespace" value="CompanyService"></parameter> <beanmapping qname="myNS:Company" languagespecifictype="java:com.server.Company"></beanmapping></deployment>
Run (you can do it via the eclipse run dialog)
java org.apache.axis.client.AdminClient deployCompanyWS.wsdd
You have deployed your WS.
try it http://localhost:8080/axis/services/CompanyRepository?method=getCompanyData
note how the Company class is serialized through xml
-
<?xml version="1.0" encoding="UTF-8"?>
-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
<soapenv:Body> <getCompanyDataResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
-
<getCompanyDataReturn href="#id0"/> </getCompanyDataResponse>
-
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:Company" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.synaptica.info"> <companyID href="#id1"/>
-
<companyName xsi:type="soapenc:string">Test</companyName>
-
<employeeNames xsi:type="soapenc:string">Balaji</employeeNames> <employeeNames xsi:type="soapenc:string">LSMS</employeeNames>
-
<employeeNames xsi:type="soapenc:string">LLQ</employeeNames> </multiRef><multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2311 </multiRef> </soapenv:Body>
-
</soapenv:Envelope>
to undeploy
-
<undeployment>
-
xmlns="http://xml.apache.org/axis/wsdd/">
-
<!– Services from SommaService WSDL service –>
-
<service name="CompanyRepository">
-
</service></undeployment>
java org.apache.axis.client.AdminClient undeploy.wsdd
To create Java Helper class to call the web service just created:
java org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/services/CompanyRepository?wsdl
english
italiano
Ultimi commenti
RSS