After my visits to Moscow, I gained lots of interest in Russia,Russians and their culture,sociology,history...
I started searching for books giving me a hint on their sociology
Here are a few...
Rusya'da Başarısız Olmanın Yollari.
The writer is a Turkish journal (Radikal Newspaper) living in Moscow for several years.In his book,he describes what to do in order to be unsuccessful in Moscow.
His main advice is 'Use previous visitor's experience' and second is 'Drink vodka with Russians', honestly I did not get any other advice.Read if you have much time, not a great resource.
Other's were also far from my expectations but here is the list...
SSCB'den Dönüş
The famous French writer Andre Gide's impressions of the soviets during his visit to USSR for the funeral of famous Russian writer Gorki.The books contains critics on the soviet system of those days.
Very short book of a little more than 100 pages and a little boring.
Rus Devriminin Gölgesindeki Kadınlar
Memories of 15 Russian women before, during and after the revolution.The book shows how people worked so hard and with extreme devotion.
Worth reading.
Kadınlar ve Perestroyka
Yet another book on soviet women but this time long after the revolution and during the perestroyka days. The book tells how hard was the living and working conditions of women were during the end of soviet era.
Sovyetler Birliğinin Çöküşü Üzerine Anti-tezler
I really did not get anything of the writers points and what his claims are.
I did not get who or what is he blaming for the collapse.
It was just a waste of time and money.
Rusya'nın Dönüşümü
The book is a collection of articles of the writer published in a national newspaper.
KINGS OF THE KREMLIN: Leaders from Ivan the Terrible to Boris Yeltsin
I found this book at METU library. Gives short biography of Russian leaders, also mentions about the important of actors of those days.
Nice to read.Good content.Here is the amazon.com link.
25 November 2006
22 November 2006
Java based implementation of Apriori Data Mining Algorithm
This is my favor to CS grad students studying datamining:). Possibly this will be an assignment for you.Below is a brief description of Apriori with Java source codes.
Apriori is a well known algorithm for association rule mining, mainly used for market basket like data analysis.For example you are given a list of transactions, you are to find the rules such as
"90% of customers buying coffee and sugar also buy cream".
For the market basket data analysis, one needs two steps:
first determine the frequent item sets then form the association rules from these sets.
While forming the frequent item sets the Apriori principle is simple: Any subset of a frequent itemset must be frequent. Before starting to give the algorithm steps, let me give 2 definitions, support and confidence.
Support of an itemset X isfraction of transactions in D that contain X
Confidence c of an association rule X ⇒ Y in D is Fraction of transactions which contain the itemset Y from the subset of transactions from D which contain the itemset X.
First determine the frequency of each single item.
Then generate candidate sets, for each k-item
frequent set,join with itself to generate the candidates.
Next, prune candidates that don't match the apriori principle stated above.
Calculate the frequencies of the pruned candidates and now you have the item sets of size k+1.
After you have formed the frequent item sets not you need to generate association rules.
For each frequent itemset X
For each subset A of X, form a rule A (X – A)
Delete those rules that do not have minimum confidence
Computation of the confidence of a rule A ==> (X – A)
Confidence(A==>(X-A))=support(X)/support(A)
Thats all!,for the source code
Apriori.java -- the appriori implementation
Kume.java -- helper class, implementation of Set which supports subsets(k) and minus() operations
Apriori is a well known algorithm for association rule mining, mainly used for market basket like data analysis.For example you are given a list of transactions, you are to find the rules such as
"90% of customers buying coffee and sugar also buy cream".
For the market basket data analysis, one needs two steps:
first determine the frequent item sets then form the association rules from these sets.
While forming the frequent item sets the Apriori principle is simple: Any subset of a frequent itemset must be frequent. Before starting to give the algorithm steps, let me give 2 definitions, support and confidence.
Support of an itemset X isfraction of transactions in D that contain X
Confidence c of an association rule X ⇒ Y in D is Fraction of transactions which contain the itemset Y from the subset of transactions from D which contain the itemset X.
First determine the frequency of each single item.
Then generate candidate sets, for each k-item
frequent set,join with itself to generate the candidates.
Next, prune candidates that don't match the apriori principle stated above.
Calculate the frequencies of the pruned candidates and now you have the item sets of size k+1.
After you have formed the frequent item sets not you need to generate association rules.
For each frequent itemset X
For each subset A of X, form a rule A (X – A)
Delete those rules that do not have minimum confidence
Computation of the confidence of a rule A ==> (X – A)
Confidence(A==>(X-A))=support(X)/support(A)
Thats all!,for the source code
Apriori.java -- the appriori implementation
Kume.java -- helper class, implementation of Set which supports subsets(k) and minus() operations
19 November 2006
11 August 2006
Train Supplements
An interrailer's main concern is the extra costs,most importantly supplements that you have to pay on certain trains in addition to your interrail ticket.
Below, I list the supplements being payed during our interrail trip in July 2006.
Brugge->Paris: 11.00 EUR [thalys fast train]
Paris->Irun: 17.50 EUR [night train couchette]
Irun->Madrid: 6.50 EUR
Madrid->Toledo: 13.00 EUR [return,fast train]
Madrid->Barcelona: 17.00 EUR [night train couchette]
Barcelona->Montpellier: 35EUR [BUS Linebus,no interrail discount]
Marseille->Nice: 1.50 EUR
Nice->Cannes: 1.50 EUR
Nice->Genova 5.00 EUR
Genova->Venice 22.00 EUR [night train couchette]
Venice->Florence 15.00 EUR
Roma->Bari 5.00 EUR
Bari->Patras 16.00 EUR [BlueStar FERRY,on deck]
Patras->Athens 3.20 EUR
Thesaloniki->Pythion 6.60 EUR
Pythion->Istanbul 15.00 YTL
08 August 2006
Book Review: Let's Go Europe 2006
Title: Lets' Go Europe 2006
Writer: Harvard University Students
Year: 2006
Pages: 1082
Definitely a must-have,must-read for every independent traveler,interrailer or eurailer.The books is organized very good and gives nice hints about the cities.List budget places for accomadation and food.Also gives information about transportation to nearby cities.Lists places to visit and how you can reach there.The price $14.99 is a bargain for this book.
During my July 2006 interrail trip I carried this book with me every single day.Just but it,you won't regret.
07 August 2006
Hostels of Interrail July 2006
Below is the map of places that we have stayed during the July 2006 Interrail tour. Move your mouse over the red points to see the name of Hotel/Hostel.
You can see details from http://ulasergin.myhostelworld.com
You can see details from http://ulasergin.myhostelworld.com
01 August 2006
Interrail Photos
I have completed uploaded interrail pics, nearly 1700 pics of 4GB.But kodak's site is terrible to view it.I will have to swich to yahoo photos when I have time.
http://adobe.kodakgallery.eu.com/I.jsp?c=aifwclj1.2yoc1pnh&x=0&y=-xznymb
http://adobe.kodakgallery.eu.com/I.jsp?c=aifwclj1.2yoc1pnh&x=0&y=-xznymb
31 July 2006
Home sweet home!
The interrail trip we have been planning for the last 6-8 months is now history!!We have visited 19 cities in 8 countries.
During this trip we had 24 train journeys(some local,some international) and 1 bus,1 minibus(rented),1 plane ,1 ferry trip which which are all international.
I have posted the plan in my previous post and I am happy to say that most of the things went according to the plan.The map shows the visities we have visited and differen colored lines indicate differen ways of transportation which is also noted on the line.
After 1 month, it is good to be home.
28 June 2006
Interrail Plan
Here is my plan for the 1 month interrail trip during July ,I hope everyhing goes as planned.
The number shows the day in July.
1 – Amsterdam
2- Amsterdam
3- Den Haag Rotterdam gez.
Amsterdam kalis
4-Amsterdam->Brugge yola cik
Brugge gez
5- Brugge de kal.
Belki Bruksele git-gel
6-Sabah’tan parise yola cik
7- Paris gez
8- Paris Gez
9- Paris’de dolas GeceTreni ile Madrid’e git
10- Oglen Madride in
11-Madrid Gez
12-Mardid gez
Belki toledo git-gel
13-Madrid den Barcelonaya git.Barcelona gez
14-Barcelona gez
15-Barcelonadan Marsilya ya git
Marsilya gez
16-Marsilya gez
17-Marsilya dan Nice e git
Nice gez
18- Nice Monaco belki Cannes gez
19- Nice’den Genoa’ya git.Gece treni ile Venedik
20-Venedik gez
21- Venedik ten Floransaya git Floransa gez
22- Floransa gez
Ogleden sonra Pisa’ya git gel
23- Floransa dan Roma ya git
Roma gez
24- Roma gez
vatikan
25- Roma gez gece treni ile Bari
26- Bari gez
Feribotla yunanistan
27- Igoumenitsa dan otobus ile Selanik git
28- Selanik gez
20 trenine bin
29- sabah 8 Sirkeci
24 May 2006
ZAAL '96 Graduates met after 10 years
1996 graduates of Zonguldak Ataturk Anatolian High School met in Zonguldak after 10 years.
It was a lovely and warm meeting. The list of attendees was Ulas,Seba,Banu,Ayca,Vural,Serdar(&wife),Hakan(&wife),Melih,Sertan,Ozge,Ceyda,Ozgur.
We first met at SahilCafe on the beach side, as the sun grew hotter we went to Doktorlar Lokali at Fener, we talked till the evening and decided to meet for breakfast the next morning an Iliksu. Iliksu beach side has changed a lot, several places offer bruch now.
22 May 2006
Steps to interrail: 3
The hardest step to interrail is completed. I got the Schengen visa from the Netherlands.Now all I have to do is to wait till the flight date. Let me briefly tell the steps for visa.
I read through the web page of missions of the Netherlands in Turkey. Their site has a word document listing the required documents for visa application. It listed lots of lots of documents. I collected them, also I went to their place and asked for a Visa application form which also had a list of documents for visa application.
I went to Anadolu Sigorta for travel insurance and the insurance for European States valid for one month costed me 16EUR.
Finally I went to their place again to apply for the visa, 35EUR visa fee should be payed for the application and my visa was ready in 2 days.
The previous step.
I read through the web page of missions of the Netherlands in Turkey. Their site has a word document listing the required documents for visa application. It listed lots of lots of documents. I collected them, also I went to their place and asked for a Visa application form which also had a list of documents for visa application.
I went to Anadolu Sigorta for travel insurance and the insurance for European States valid for one month costed me 16EUR.
Finally I went to their place again to apply for the visa, 35EUR visa fee should be payed for the application and my visa was ready in 2 days.
The previous step.
10 May 2006
Fener-Balat region tour
Last week I attended Fener-Balat region tour with Istanbul Travel Club. As far as I understand this region was the old Istanbul and mainly where the non-muslim folk of the Ottoman Empire lived. It is full of historical places, mostly churches.
And don't forget the Vatican of the Orthodox community, the Fener Greek Patriarche.
The Greek High School near the Patriarche.
Also nearly Pieere Loti's Cafe has a great view although it is hard to climb there:)
In brief,I can say that the region is really lovely and historic.
And don't forget the Vatican of the Orthodox community, the Fener Greek Patriarche.
The Greek High School near the Patriarche.
Also nearly Pieere Loti's Cafe has a great view although it is hard to climb there:)
In brief,I can say that the region is really lovely and historic.
30 April 2006
Steps to interrail: 2
Yesterday we bought our interrail tickets from Genctur at Taksim. We are in the process of collecting papers for visa .
The pic shows the interrail tickets together with corendon airlines tickets to the Netherlands which I bought online but obtained the printed versions for visa application from their office in Kozyatagi , guidebooks, superfast ferry brochure which they kindly posted via mail upon my request and passports. There is one huge step left: getting the visa.
We are signing papers in the Genctur office for buying the railpass.
The previous step
25 April 2006
Book Review: Europe Through the Back Door 2006
Title: Rick Steves' Europe Through the Back Door 2006 : The Travel Skills Handbook
Writer: Rick Steves
Year: 2006
Pages: 630
This is the first book review from the series listed in my previous blog entry: My Book List for Summer 2006 Interrail Planning I hope more reviews will come soon.
This is not a guidebook in the commonsense.It is so-called as 'Read-before-go book '. The book is organized in two sections, the first section is a travel skills handbook dealing with Planning an ininerary,transportation,money,sleeping and eating.. etc. as the title already implies
And the second section gives what the author calls 'backdoors'.List places that are not discovered by tourism agencies yet or not getting necessary attention. The counties mentioned includes: Italy, Portual, Spain, Morroco, Frace, Belgium, Netherlands, Germany, Austria, Switzerland, British Isles and Scandanavia.
The auther list few ,if not one, cities in each coutry and gives hints and beautities of that city.
The first travel skills section is helpful although you might find these information everywhere and also internet.It is still good to have all these information packed in one place completely.
The second section is for people looking for not crowded, relatively calm places in Europe. If you are looking for info about popular sightseeings of these countries you should get a guidebook which is also recommended by the author.
Accompanying site for the book can be found at ricksteves.com . I can not decide whether to recommend buying or not buying this book. The amazon link is here for you to further investigate.
18 April 2006
Book Review: Yolculuga Cikanlarin Kucuk El Kitabi
Title: Yolculuğa Çıkanların Küçük El Kitabı Okumaları, Hatırlamaları ve Paylaşmaları İçin; Öneriler, Gözlemler ve Andaçlar
Writer: David Scott, William W. Forgey
Year: 2003
Pages: 184
As the book name already tells this is a handbook for travellers.It contains 377 tips for travelers before and during the travel period.The book should be even smaller but the publisher prefered to use big fonts to make the book look 'useful'.
I don't think the book contains life-saver tips, you may still want to give it a try since it is cheap 3.58YTL. I bought it from Ideefixe.
15 April 2006
Book Review: Moskova ve Petersburg Cep Rehberi
Title: Moskova ve Petersburg Cep Rehberi
Writer: Neil Winson
Year: 2003
Pages: 140
I bougth this book before my second trip to Moscow.Although I did not have time to validate the contents of the book due to hard work I still will mention about the book.
It is a small sized thin pocket book as the name implies, has a small map of cental Moscow and Moscow metro in the front cover and a small map of central St.Petersburg and Petersburg metro in the back cover of the book.
The book gives short history, important places to see and hotel&restaurant info for the two cities.
I bought it from Kadikoy Alkim bookstore, you may pferer to buy online istead.
13 April 2006
Steps to interrail:1
Today I competed the first step to interrail. I talked with my managers in the company that I want to resign and leave by June 30th. And they accepted.Now it is clear that I have a one month holiday I can devote to interrail.
I have already bought my plane ticket from Corendon airlines for 19EUR(54EUR with tax) to Amsterdam and my 5 travel books that I have already listed in my previous blog entry "My Book List for Summer 2006 Interrail Planning " already arrived.
The brocure I requested from Superfast Ferries for the Italy-Greece passing arrived, including information about timetables and fares.
Now the next and the hardest step of all is to obtain the visa.
07 April 2006
The BEST! Music Album Ever!!
Metallica ...And Justice For All
Today I realized that I've been listening to this album for 14 years! (since 1992) and I still love it . When I bought this album I was at 2nd year of my secondary school education. I keep listening it over and over and never get bored. I can not even choose which song is the best. Every single song is this great album is a masterpiece.
The album is definitely number 1 in my list of Best Metal Albums of 90's
You should definetely buy this album.Here is the amazon.com link. For Turkish fans here is the Ideefixe link.
Today I realized that I've been listening to this album for 14 years! (since 1992) and I still love it . When I bought this album I was at 2nd year of my secondary school education. I keep listening it over and over and never get bored. I can not even choose which song is the best. Every single song is this great album is a masterpiece.
The album is definitely number 1 in my list of Best Metal Albums of 90's
You should definetely buy this album.Here is the amazon.com link. For Turkish fans here is the Ideefixe link.
06 April 2006
You can Google me
Since 1996, I've been posting questions or answering other posters' questions on several sites, forums and newsgroups. Most of them are about Java and related technologies, few are on database ,Linux and older ones dated between 1996-2000 are on C. You can find some of them here, mainly from the usenet archieves.
30 March 2006
Back in Moscow Again
I'am back in Moscow again for the third time. Last time I returned to Turkey with a russaian airway company Aeroflot, the plane was rather old which lead to lots of jokes. Also one intresting thing was the plane being full of Japanase tourists.
This time I stay in Hotel Erian, which is an apart hotel. The 'room' I stay has a bedroom with french bed, huge wardrobe , a living room with a TV and 2 sofas, and kitchen with a table and 4 chairs, refrigirator,oven... shortly a full apartment flat.In fact the so-called hotel is an apartment with 20+ floors. On the left is the photo of apart-hotel Eridan.
And here is the inside picture of metro station Chertanoskaya. If you don't know how to read Cryllic letters it may be hard to get off at the right station.
Below is the tallest building in Europe that people live in,it is said to have nearly 1000 flats.
More comments (in Turkish) in Turkish-interrailers group.You should be a member to read.Message number 6131.
27 March 2006
From Russia with Love
Between 9 and 23th of March I was in Moscow for the second time.This time I stayed in President Otel which has built during the Soviet Era for meetings and accomodation of Communist Party members. The hotel was huge but old fashioned. The location is near Polyanka metro station and is close to city center.
Before arrival I was concerned about bad weather conditions, but it was not as bas as I guessed. It did not snow so heavily during my visit. And when it snowed the roads are cleaned immediately , the problem is with the sidewalks where snow turned into a stone-like structure and very slippy.
08 March 2006
Book Review: Uzaklar Cagirinca
Title: Uzaklar Cagirinca
Writer: Orhan Kural
Year: 2005
Pages: 196
The writer is an intinerant that has traveled to 187 countries of the world!. The short and small sized book is organized into two sections.First section is in a 'textbook' format (you may consider it as normal since the writer is a lecturer in I.T.U) that tells places to visit in Turkey, 7 wonders of the world, diseases and troubles that intinerants may face during world travel, top 50 things to do/places to see in world ...
And the second section of the book tells the travel memories of the writer during his several visits. The book is cheap (3.83YTL),I bought it from Ideefixe you may give it a try if you have time but know that it is not the best.
07 March 2006
Book Review: Avucumda Patikalar
Title: Avucumda Patikalar
Writer: Z. Gulin Akoz
Year: 2005
Pages: 280
I bought this book from Ideefixe. I did not look inside it, just read the reviews online. Well..it is a terrible book.It is catagorized as a travel book but...I really don't know what is it. She tells a little bit about the places she saw but moslt personal things about her. Just stay out of it!
06 March 2006
My FC4 box is counted
My Fedora Core 4 PC at home is counted at counter.li.org and I am the 394277th counted user on that site.
Turkish interrailers met on Saturday
Last saturday(04.03.2006) I was at Turkish interraillers meeting. The meeting was held at Guitar Cafe, Kadikoy. Nearly 40 interrailers of whom 10 have previous interrail experience met.There was a warm atmosphere, people shared lots of information and spent good time. It was a very beneficial meeting, I hope it will be repeated in future.
03 March 2006
Checking file existence with a shell script
Sometimes you need to check whether a file exists, in a shell script.
Here is how:
For Unix (Korn Shell on Sun Solaris)
if [[ -a myfile.txt ]]; then
echo myfile.txt exists
else
echo myfile.txt does not exist
fi
exit 0
and for DOS
if exist myfile filefound
echo File Not Found
exit 1
:filefound
echo File Found
exit 0
that simple!
Here is how:
For Unix (Korn Shell on Sun Solaris)
if [[ -a myfile.txt ]]; then
echo myfile.txt exists
else
echo myfile.txt does not exist
fi
exit 0
and for DOS
if exist myfile filefound
echo File Not Found
exit 1
:filefound
echo File Found
exit 0
that simple!
Book Review: Avrupa
Title: Avrupa "Utopya'dan Avrupa'ya"
Writer: Michael Gehler
Year: 2002
Pages: 149
In fact the book name is a little misleading,this is a thin book telling the brief history of European Union not Europe. European Union should be a better book title but then it would look boring, may be this is a marketing trick who knows.
Anyway, the books tells the hitory of how the United States of Europe has evolved and becase a reality. It gives an intoduction starting with 16-18th centuries and details it starting from 1945. Then it tells about how the European Economic Union turned into European Union and how several countries joined.
It book ends with a chronology of European Union between 1945 and 2002.
The book is so much into political science area so it may seem boring if you are not much interested.
27 February 2006
How to obtain caller method (jdk 1.4+)
Sometimes you want to know which class/method called your function. Starting with Java 1.4, java.lang.StackTraceElement provides an easy way to accomplish this. Here is how
StackTraceElement[] telements = new Exception().getStackTrace();
String callerClass = telements[1].getClassName();
String callerMethod = telements[1].getMethodName();
The array's 0th item is your method and 1st item is the method that called your method.
StackTraceElement[] telements = new Exception().getStackTrace();
String callerClass = telements[1].getClassName();
String callerMethod = telements[1].getMethodName();
The array's 0th item is your method and 1st item is the method that called your method.
26 February 2006
How to Build A DLL and Call It From Another C Program, using MS VC++ 6.0
My professional software development experience is mainly on server side Java/J2EE development. Recently, I had to build a DLL for –let me say – integration with a third party product. Although I was very proficient in the C programming language in collage days, it’s been years ago and it’s been based on vi&gcc&xxgdb development on Unix (mainly Sun Solaris and Digital Alpha workstations) and Linux.
I had trouble in finding a complete and explainatory document for all steps so I decided to write one. I decided to build this short tutorial to guide people who needs to build a DLL and call that DLL from some other program. This tutorial is consisted of two parts, the first section shows the details for building a DLL using MS VC++ 6.0 and the second section shows the way to call it from another C/C++ program. My function takes to char pointers and returns a byte pointer.
I have Microsoft Visual C++ 6.0 Enterprise Edition installed on my Windows XP SP2 computer.
Before starting the tutorial I strongly recommend you to download the free utility program InspectEXE which helps us to explore DLL symbols. I also want to note that I only have a few experience with DLLs and MSVC++ so the way I show here may not be the only and supported /clearer way but this is one way I figured it out and it works. Use it at your own risk :)
1. Building the DLL
Create a new DLL Project (File->New->Projects->Win32 Dynamic-Link Library)
We choose BuildDLL as the project name.
Press the OK button. On the next dialog choose “A DLL that exports some symbols” and press Finish.
Now the IDE builds the source files for you to explore.
BuildDLL.h and BuildDLL.cpp
If you want your function residing in the DLL to be called from outside your function must be preceded with __declspec(dllexport). BuildDLL.h contains a macro for this as a shortcut.
#define BUILDDLL_API __declspec(dllexport)
In order to define my trial function that takes two char*s and returns a byte*
I add the lines
typedef unsigned char byte;
BUILDDLL_API byte* myTrialFunction(char*,char*); to BuildDLL.h
and the following code listing to BuildDLL.cpp
extern "C" BUILDDLL_API byte* myTrialFunction(char* param1,char* param2)
{
byte* p = (byte*) malloc(sizeof(byte));
*p='a';
return p;
}
Build->BuildDLL.dll(F7) resulted in my dll to be build. Since I have installed InspectExe before, I do right click on the dll open the properties window and choose Exports to see what my dll has exported.
Well., sort of strange names… I check the C++ Style names checkbox and see
Here comes the tip of the first section of the tutorial:
My function’s name is myTrialFunction and I will use this function name when I want to load the dll and use the functionality from another program. In order to avoid the mangled name “?myTrialFunction@@YAPAEPAD0@Z” you should add ‘extern “C”’ to your function decleration.If you fail to do this, the program calling your dll’s function with the name “myTrialFunction” will not be able to locale the method with GetProcAddress().
So the line in BuildDLL.dll becomes
extern "C" BUILDDLL_API byte* myTrialFunction(char*,char*);
and BuildDLL.cpp becomes
extern "C" BUILDDLL_API byte* myTrialFunction(char* param1,char* param2)
{
byte* p = (byte*) malloc(sizeof(byte));
*p='a';
return p;
}
Note: You should add #include stdlib.h to use malloc()
So the DLL export symbols look like
So, this is the end of first section, we have seen how to build a DLL that contains a function having two char pointers as arguments and returning a byte pointer. In the next section we will build another C++ program to load the BuildDLL.dll and call that myTrialFunction function.
2. Calling the function from the DLL
Create a new project by clicking File->New->Project->Win32 Console Application
We chose DLLCaller as the project name.
Choose “A Simple Hello World!” application from the next window and click finish.
There are three API calls that you should know at this point to load a DLL and call a function in it.
LoadLibrary() : Locates and loads the DLL into memory
GetProcAddress(): Gives you a function pointer to your function
FreeLibrary() : To release resources when you are done with the DLL.
Also BuildDLL.dll should be in the DLL lookup path of your new program so you must copy the BuildDLL next to DLLCaller.exe (you can also place it in system32 which is a very ugly way)
First we add the following two lines to define a shortcut to the function pointer.
typedef unsigned char byte;
typedef byte* (*ptr_myTrialFunction)(char*,char*);
and #includefor DLL calling API functions.
And the main() method in DLLCaller.c becomes
// DLLCaller.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
HINSTANCE hDLL = NULL; //A DLL instace
Ptr_myTrialFunction func; //Pointer to my function
byte* function_retval; //return value of the function
hDLL = LoadLibrary("BuildDLL"); // Load the DLL
if(hDLL==NULL)
{
//If the LoadLibrary() call can not locate and load the DLL
//it returns NULL
fprintf(stderr,"%s\n","Unable to load DLL");
return -1;
}
else //DLL is loaded
{
func = (Ptr_myTrialFunction)GetProcAddress(hDLL, "myTrialFunction");
//first parameter to the GetProcAddress is the DLL instance containing the function
//second parameter is the name of function in the DLL
if(func==NULL)
{
//If the GetProcAddress() call can not find the function
//it returns NULL
fprintf(stderr,"%s\n","Unable to locate function");
return -1;
}
else // function is found and a pointer to it is located
{
function_retval=func("a","b");
if(function_retval==NULL)
{
fprintf(stderr,"%s\n","Function can not return null?");
return -1;
}
else // function returned successfully
{
fprintf(stdout,"%d\n",*function_retval);
}
}
}
fprintf(stderr,"%s\n","Finished!");
return 0;
}
Executing the program yields the following result
Where 97 is the ASCII code of ‘a’
Final note for the curious: If we do not put the 'extern "C"' in the decleration of myTrialFunction in the DLL side we can still call the function with its manged name ?myTrialFunction@@YAPAEPAD0@Z" so the line
func = (Ptr_myTrialFunction)GetProcAddress(hDLL, "myTrialFunction");
will become
func = (Ptr_myTrialFunction)GetProcAddress(hDLL, "?myTrialFunction@@YAPAEPAD0@Z");
and it also works.
Good luck!
I had trouble in finding a complete and explainatory document for all steps so I decided to write one. I decided to build this short tutorial to guide people who needs to build a DLL and call that DLL from some other program. This tutorial is consisted of two parts, the first section shows the details for building a DLL using MS VC++ 6.0 and the second section shows the way to call it from another C/C++ program. My function takes to char pointers and returns a byte pointer.
I have Microsoft Visual C++ 6.0 Enterprise Edition installed on my Windows XP SP2 computer.
Before starting the tutorial I strongly recommend you to download the free utility program InspectEXE which helps us to explore DLL symbols. I also want to note that I only have a few experience with DLLs and MSVC++ so the way I show here may not be the only and supported /clearer way but this is one way I figured it out and it works. Use it at your own risk :)
1. Building the DLL
Create a new DLL Project (File->New->Projects->Win32 Dynamic-Link Library)
We choose BuildDLL as the project name.
Press the OK button. On the next dialog choose “A DLL that exports some symbols” and press Finish.
Now the IDE builds the source files for you to explore.
BuildDLL.h and BuildDLL.cpp
If you want your function residing in the DLL to be called from outside your function must be preceded with __declspec(dllexport). BuildDLL.h contains a macro for this as a shortcut.
#define BUILDDLL_API __declspec(dllexport)
In order to define my trial function that takes two char*s and returns a byte*
I add the lines
typedef unsigned char byte;
BUILDDLL_API byte* myTrialFunction(char*,char*); to BuildDLL.h
and the following code listing to BuildDLL.cpp
extern "C" BUILDDLL_API byte* myTrialFunction(char* param1,char* param2)
{
byte* p = (byte*) malloc(sizeof(byte));
*p='a';
return p;
}
Build->BuildDLL.dll(F7) resulted in my dll to be build. Since I have installed InspectExe before, I do right click on the dll open the properties window and choose Exports to see what my dll has exported.
Well., sort of strange names… I check the C++ Style names checkbox and see
Here comes the tip of the first section of the tutorial:
My function’s name is myTrialFunction and I will use this function name when I want to load the dll and use the functionality from another program. In order to avoid the mangled name “?myTrialFunction@@YAPAEPAD0@Z” you should add ‘extern “C”’ to your function decleration.If you fail to do this, the program calling your dll’s function with the name “myTrialFunction” will not be able to locale the method with GetProcAddress().
So the line in BuildDLL.dll becomes
extern "C" BUILDDLL_API byte* myTrialFunction(char*,char*);
and BuildDLL.cpp becomes
extern "C" BUILDDLL_API byte* myTrialFunction(char* param1,char* param2)
{
byte* p = (byte*) malloc(sizeof(byte));
*p='a';
return p;
}
Note: You should add #include stdlib.h to use malloc()
So the DLL export symbols look like
So, this is the end of first section, we have seen how to build a DLL that contains a function having two char pointers as arguments and returning a byte pointer. In the next section we will build another C++ program to load the BuildDLL.dll and call that myTrialFunction function.
2. Calling the function from the DLL
Create a new project by clicking File->New->Project->Win32 Console Application
We chose DLLCaller as the project name.
Choose “A Simple Hello World!” application from the next window and click finish.
There are three API calls that you should know at this point to load a DLL and call a function in it.
LoadLibrary() : Locates and loads the DLL into memory
GetProcAddress(): Gives you a function pointer to your function
FreeLibrary() : To release resources when you are done with the DLL.
Also BuildDLL.dll should be in the DLL lookup path of your new program so you must copy the BuildDLL next to DLLCaller.exe (you can also place it in system32 which is a very ugly way)
First we add the following two lines to define a shortcut to the function pointer.
typedef unsigned char byte;
typedef byte* (*ptr_myTrialFunction)(char*,char*);
and #include
And the main() method in DLLCaller.c becomes
// DLLCaller.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
HINSTANCE hDLL = NULL; //A DLL instace
Ptr_myTrialFunction func; //Pointer to my function
byte* function_retval; //return value of the function
hDLL = LoadLibrary("BuildDLL"); // Load the DLL
if(hDLL==NULL)
{
//If the LoadLibrary() call can not locate and load the DLL
//it returns NULL
fprintf(stderr,"%s\n","Unable to load DLL");
return -1;
}
else //DLL is loaded
{
func = (Ptr_myTrialFunction)GetProcAddress(hDLL, "myTrialFunction");
//first parameter to the GetProcAddress is the DLL instance containing the function
//second parameter is the name of function in the DLL
if(func==NULL)
{
//If the GetProcAddress() call can not find the function
//it returns NULL
fprintf(stderr,"%s\n","Unable to locate function");
return -1;
}
else // function is found and a pointer to it is located
{
function_retval=func("a","b");
if(function_retval==NULL)
{
fprintf(stderr,"%s\n","Function can not return null?");
return -1;
}
else // function returned successfully
{
fprintf(stdout,"%d\n",*function_retval);
}
}
}
fprintf(stderr,"%s\n","Finished!");
return 0;
}
Executing the program yields the following result
Where 97 is the ASCII code of ‘a’
Final note for the curious: If we do not put the 'extern "C"' in the decleration of myTrialFunction in the DLL side we can still call the function with its manged name ?myTrialFunction@@YAPAEPAD0@Z" so the line
func = (Ptr_myTrialFunction)GetProcAddress(hDLL, "myTrialFunction");
will become
func = (Ptr_myTrialFunction)GetProcAddress(hDLL, "?myTrialFunction@@YAPAEPAD0@Z");
and it also works.
Good luck!
21 February 2006
Book Review: Kirmizi Fener Sokagi
Title: Kirmizi Fener Sokagi
Writer: Mehmer Unver
Year: 2005
Pages: 446
I have been in Amsterdam in 2003 for 1 month.I loved the city which looked liked a movie set of 16th-18th century. That's why I decided to give this book a try.
The story of the book takes place in Amsterdam, specifically the famous Red Light District.As far as I remember, it was written in one of the newspapera that the story is based on true stories of people that the writer has interviewed.
The story tells about three woman of two working in the red light district and one is an immigrant die to her ex-membership of an illagal organization and a father looking for his son.The story is boring, the events and places are boring, it is hard to read up to the end.I do not recommend this book to anyone.
Writer: Mehmer Unver
Year: 2005
Pages: 446
I have been in Amsterdam in 2003 for 1 month.I loved the city which looked liked a movie set of 16th-18th century. That's why I decided to give this book a try.
The story of the book takes place in Amsterdam, specifically the famous Red Light District.As far as I remember, it was written in one of the newspapera that the story is based on true stories of people that the writer has interviewed.
The story tells about three woman of two working in the red light district and one is an immigrant die to her ex-membership of an illagal organization and a father looking for his son.The story is boring, the events and places are boring, it is hard to read up to the end.I do not recommend this book to anyone.
19 February 2006
My amazon.com reviews
I have made a few reviews on computer books and music albums at amazon.com site, some time ago.
You can view them all here.
I lost the password for that account, here is the list of reviews with the newest account.
Also I have a list named Best Metal Albums of 90's on amazon.com and trust me they are really good, I own them all.
You can view them all here.
I lost the password for that account, here is the list of reviews with the newest account.
Also I have a list named Best Metal Albums of 90's on amazon.com and trust me they are really good, I own them all.
My Book List for Summer 2006 Interrail Planning
Here is the list of books that I have ordered from Amazon for planning my interrail trip for 2006 summer.Unfortunately amazon.com service is too slow, I placed the order in 20th of January and estimated delivery date is 28th of Match!.
So I just list the book names for now but hopefully I will present reviews for each of them as soon as I get the books.
- Independent Travellers Europe by Rail 2006 : The Inter-railer's and Eurailer's Guide (Independent Travellers - Thomas Cook) $15.61
- Lonely Planet Western Europe (Lonely Planet Western Europe) $18.47
- Lonely Planet Europe Phrasebook $8.99
- Let's Go 2006 Europe (Let's Go Europe) $10.19
- Rick Steves' Europe Through the Back Door 2006 : The Travel Skills Handbook $14.93
Book Review : Siempre Havana
Title: Siempre Havana
Writer: Asli Pelit
Year: 2005
Pages: 184
Language: Turkish
The writer has stayed for a long time in Havana(She doesn't tell why and how long in the book).She tells about the architecture, history, food,life, music in Havana.
Also she mentions these topics for all Cuba but I find the book a little boring.She tells evething as if you are already in Havana.Goes too much into irrevelant details. I should also note that one of my friends loved the book.(So you also may)
Personally, I don't recommend but If you are really interested in different cultures and especially Cuba, you may give it a try.
Siempre Havana Book Cover
The book is available from Ideefixe
Writer: Asli Pelit
Year: 2005
Pages: 184
Language: Turkish
The writer has stayed for a long time in Havana(She doesn't tell why and how long in the book).She tells about the architecture, history, food,life, music in Havana.
Also she mentions these topics for all Cuba but I find the book a little boring.She tells evething as if you are already in Havana.Goes too much into irrevelant details. I should also note that one of my friends loved the book.(So you also may)
Personally, I don't recommend but If you are really interested in different cultures and especially Cuba, you may give it a try.
Siempre Havana Book Cover
The book is available from Ideefixe
Book Review : Bir Bilet Al
Title: Bir Bilet Al
Writer: Gizem Altin
Year:2000
Pages: 217
Language: Turkish
I personally liked this book.It is written in a warm-diary form.The book is about the memories of the writer during her interrail travel in 2000.After she got fired, she organized this beautiful 5 week trip with her compansation money.
The book is consisted of two sections, first section tells about the countries (mainly Greece, Italy, France, Spain) and cities she has visited, places she has seen, friends she has made and money spent.
In the second section she gives tips about interrail trip organization, places to see, things to keep in mind, hostels to stay, books to read and several useful recommendations more.
It is one of the very rare interrail publications in Turkish language. I bought it from Ideefixe and totally recommend it to you. For the web page of the book click here
Writer: Gizem Altin
Year:2000
Pages: 217
Language: Turkish
I personally liked this book.It is written in a warm-diary form.The book is about the memories of the writer during her interrail travel in 2000.After she got fired, she organized this beautiful 5 week trip with her compansation money.
The book is consisted of two sections, first section tells about the countries (mainly Greece, Italy, France, Spain) and cities she has visited, places she has seen, friends she has made and money spent.
In the second section she gives tips about interrail trip organization, places to see, things to keep in mind, hostels to stay, books to read and several useful recommendations more.
It is one of the very rare interrail publications in Turkish language. I bought it from Ideefixe and totally recommend it to you. For the web page of the book click here
Subscribe to:
Posts (Atom)