Saturday, January 15, 2011

How a dll using in vc++

I was trying to learn DLLs and nothing was really explaining anything; it was just code for you to look at and wonder what was going on. For this article, I assume you know how to use the features of your compiler, such as setting directory paths and such.
To set up the project, select Win32 Console Application, and on the advanced tab, select DLL and empty project options. DLLs are not as hard as you might think they are. First, make your header file; call this DLLTutorial.h. This file is like any other header file in that it has function prototypes.

#ifndef _DLL_TUTORIAL_H_
#define _DLL_TUTORIAL_H_
#include <iostream>

#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

extern "C"
{
   DECLDIR int Add( int a, int b );
   DECLDIR void Function( void );
}
The first two lines instruct the compiler to include this file only once. The extern "C" tells the compiler that it is okay to use this in C or C++.
There are two ways of exporting functions in VC++:
  1. Use __declspec, a Microsoft-specific keyword.
  2. Create a Module-Definition File (.DEF). The first way is a tad bit easier to do than the second, but both work just fine.
__declspec(dllexport) exports the function symbols to a storage class in your DLL. I defined DECLDIR to do this function when the line
#endif
#define DLL_EXPORT
is not present in the source file(s). In this case, you will export the functions Add(int a, int b) and Function().
Now, you need to make a source file that you'll call DLLTutorial.cpp.

#include <iostream>
#include "DLL_Tutorial.h"
#define DLL_EXPORT
extern "C" { DECLDIR int Add( int a, int b )
{ return( a + b ); }
DECLDIR void Function( void )
{ std::cout << "DLL Called!" << std::endl; } }

This is where you define all of your functions. Int Add(int a, int b) simply adds two numbers and void Function(void) just informs you that your DLL was called.
Before I show you how to use the DLL, I want to tell you about the Module-Definition File (.def).

Module-Definition File (.def)

A module definition file is a text file with a .def extension. It is used to export the functions of a DLL, much like __declspec(dllexport), but the .def file is not Microsoft specific. There are only two required sections in a .def file: LIBRARY and EXPORTS. Take a look at a basic .def file and then I'll explain.

The first line, 'LIBRARY', is one of the required sections. This tells the linker what to name your DLL. The next section labeled 'DESCRIPTION' is not required, but I like to put it in. It writes the string into the .rdata [from MSDN] and it tells people who might use the DLL what it does or what it's for. The next section labeled 'EXPORTS' is the other required section; this section makes the functions available to other applications and it creates an import library. When you build the project, not only is a .dll file produced, but an export library is produced with the extension .lib. In addition to the previous sections, there also are four other sections labeled NAME, STACKSIZE, SECTIONS, and VERSION. I will not cover these in this tutorial. but if you search the Internet, I think you'll find something. One more thing: A semicolon (;) starts a comment, as '//' does in C++.
Now that you have created your DLL, you need to learn how to use it in an application. When the DLL was built, it created a .dll file and a .lib file; you will need both.

Implicit Linking

There are two ways to load a DLL; one way is the easy route and the other is more complicated. The easy route is just linking to your .lib file and putting the .dll file in your new projects path. So, create a new Empty Win32 Console project and add a source file. Put the DLL you made in the same directory as your new project.

#include <iostream>
#include <DLLTutorial.h>

int main()
{
   Function();
   std::cout << Add(32, 58) << "\n";
   return(1);
}
You must link to the DLLTutorial.lib file. I did it in Project Settings, but you could use
#pragma comment(lib, "DLLTutorial.lib")

instead. Please note that I set the compiler to look into my DLL folder for the .lib file and set it to look in the directory for the DLL header. If you don't want to do this, you can always put them in the directory with your new project and use "" (quotes) instead of <>. That's how you load a DLL the easy way.

Explicit Linking

The harder way to load a DLL is a little bit more complicated. You will need function pointers and some Windows functions. But, by loading DLLs this way, you do not need the .lib or the header file for the DLL, only the DLL. I'll list some code and then explain it.

#include <iostream>
#include <windows.h>

typedef int (*AddFunc)(int,int);
typedef void (*FunctionFunc)();

int main()
{
   AddFunc _AddFunc;
   FunctionFunc _FunctionFunc;
   HINSTANCE hInstLibrary = LoadLibrary("DLL_Tutorial.dll");

   if (hInstLibrary)
   {
      _AddFunc = (AddFunc)GetProcAddress(hInstLibrary, "Add");
      _FunctionFunc = (FunctionFunc)GetProcAddress(hInstLibrary,
         "Function");

      if (_AddFunc)
      {
         std::cout << "23 = 43 = " << _AddFunc(23, 43) << std::endl;
      }
      if (_FunctionFunc)
      {
         _FunctionFunc();
      }

      FreeLibrary(hInstLibrary);
   }
   else
   {
      std::cout << "DLL Failed To Load!" << std::endl;
   }

   std::cin.get();

   return 0;
}





Monday, January 10, 2011

How To create textfiled and set font in flash as2

Paste this code in to the first frame of your flash movie


this.createTextField("mytext",1,100,100,100,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = true;

var myformat:TextFormat = new TextFormat();
myformat.font = "Courier";

mytext.text = "this is my first test field object text";
mytext.setTextFormat(myformat);

Saturday, May 1, 2010

The fastest way to over come the storage problems is a second hard drive, in addition, its great method to protect critical data. It’s not only an easy and quick way as well as it’s a cost effective, approximately 1$ per gigabyte. So if you need additional storage on your machine, this article will tell you the simplest way to push you forward towards living this experience and obtain your desired results.
Instructions to follow:
As long as you reached this part, this means that you are about to begin this exciting process, shall we delve?
  • Hard DriveFirst check if you want the Serial ATA or IDE (parallel-ATA). Although older machines have the IDE (Parallel ATA), modern ones might support only (Serial-ATA). To make sure of that, you can open up the case and try to distinguish the used drives type. Usually the IDE drives have a flat and wide ribbon cable. The SATA ones have thinner cables and no jumpers.
  • Free a room for an extra hard drive:
  • Restart your machine then log into the BIOS-Menu.
  • Hit the Standard CMOS Settings.
  • Restart your machine
  • See a trusted manufacturer to get the external hard drive you want to add , make sure that its compatible with your master hard drive
  • Turn off your machine, unplug all cords attached to it from the back and unscrew all the screws of your case.
  • Place the screws in a well know place then remove the side panel and drag it out of the case.
  • Look for the region where all flat ribbon cables (or even the SATA cables) attach to the mother board.
  • Pose the jumpers to change the drive status to a slave or a master. Follow the instructions printed on your hard drive to do so. Meanwhile you won’t have to do so if you were dealing with a SATA, as each SATA device uses only its own cable, IDEs can share devices.
  • Locate the empty bay inside your machine case.
  • Connect the ribbon cable that to your hard drive.
  • Connect the Molex power cable; you can distinguish it by the 3 thin internal wires of red, yellow, and black. Notice that SATA drive has a non similar kind of power cable.
  • Place the side panel where it was to your computer then screw it back.
  • If you reached here it’s the last step as you will have to plug all of cables, connect them back to their power source incase while installing the drive you unplugged them.
  • Now we need the computer organization to feel all the changes, and that’s why you will restart your machine. Log into BIOS startup (depending on your mother board manufacturer you can show it by either pressing F10 or DEL key on keyboard). Now check back the BIOS Auto-Detect to make sure that the additional drive got detected. Check the screen that presents the both the Primary and Slave drives, you should see the name of the new added one.
  • Once you log into it, you will face 4 settings named as following: PRIMARY MASTER\AUTOPRIMARY SLAVE\ SECONDARY MASTER\ SECONDARY SLAVE. Hit them all and change them into Auto-Detection.

Sunday, April 25, 2010

Step 1
Start at the homepage. When you go to Facebook.com, you see a screen that asks you to login or sign up for a free account. Click on "Sign Up," which takes you to a Web form.
Step 2
Fill out the form that asks for your full name, your current status, email address, a password and your birthday. You'll also have to type in a series of letters and numbers for a security check as well as check a box saying that you understand and agree to the terms of use and privacy policy. Click the "Sign up now!" button when you have completed the form.
Step 3
Wait for your confirmation email. Facebook sends this email to confirm your registration. When you get the email, click on the link in the email to confirm that you did in fact register for a Facebook account. You will then be logged into Facebook.
Step 4
Search for friends and coworkers. When you first set up a Facebook account, you have the opportunity to search your email address book for possible friends and contacts. Type in your email address and password to do a search, or try searching by school or company.
Hopefully it helps you out.

Thursday, April 1, 2010

How to Upgrade the Memory in Your Computer

The best way to improve your computer's performance is to add random-access memory (RAM). Installing new RAM is quite straightforward for most PC owners, but if you're not confident of your abilities, have a store technician do the work.

Instructions

Things You'll Need:

  • New memory cards
  1. 1
    Find out how much memory your computer has. Here's how:
  2. 2
    In Windows XP, click on Start, then Control Panel, then Performance and Maintenance, then System. In other versions of Windows, double-click on My Computer, then double-click on Control Panel, then double-click on System.
  3. 3
    In Mac OS X, find the Applications folder, double-click on the Utilities folder, and double-click on Apple System Profiler. In Mac OS 9 or earlier, select the Apple System Profiler (usually found in the Apple menu).
  4. 4
    Check your manual or manufacturer's Web site to determine whether there are open memory slots on the motherboard. Also see what the maximum amount of memory your computer can take, as well as the type, category and speed of memory it uses. For example, PC2100 DDR 133 MHz RAM means PC2100 is the type, DDR is the category, and 133 MHz is the speed in megahertz.
  5. 5
    Compare your current memory with the maximum. You have two choices: Add new memory in open slots; or, if all slots are full, replace the existing memory with new, greater-capacity modules.

Sunday, March 28, 2010

How to Upgrade a Processor

You can upgrade an older microprocessor to a newer one in easy steps. Before going ahead, you should gather information about which new CPU you need and whether your motherboard is compatible with it or not.
The compatibility of your new CPU with your motherboard can be ascertained by searching for specific information on the Internet, or checking with your trusted computer dealer.

Preparing to Upgrade to a New CPU

After purchasing the correct new CPU, make sure that adequate grounding is available before starting to replace the old CPU. To prevent damage to the fine circuits on the motherboard, wear a grounding strap attached to the computer’s chassis. This should be done several minutes before you get to work.
It is important to exercise extreme care when upgrading a CPU, because it is among the most fragile pieces of computer equipment.
CPU2 How to Upgrade a CPU

Steps to Upgrade a CPU

  • Ensure that the power supply to the computer is turned off and all accessories are detached.
  • Remove the computer’s chassis cover carefully.
  • Locate the CPU fan and heatsink and disconnect the CPU fan from its power supply.
  • Remove the CPU’s heatsink on the motherboard, and find your computer's processor located below it.
  • Remove the old CPU by lifting up the tab holding it in place, and gently pulling it out.
  • The new CPU can be inserted by matching it correctly into position.
  • Push down the tab to hold the new CPU into position.
  • A thin, uniform layer of thermal compound should be applied before placing the heatsink back into position. This thermal compound is used to ensure improved conduction of heat from CPU to the heatsink.
  • The heatsink can then be reinstalled, and the fan's wire connected back to its power supply on the motherboard.
  • The next step will be to confirm that everything is properly connected, by gently trying to move the components.
  • When you are satisfied with the new installation, screw the computer's cover back into place. You can now remove the grounding wrist-strap.
  • Plug your computer into its power source, and attach all the accessories.
  • Your computer can now be turned on and should be ready for use!

Sunday, March 21, 2010

How to Change Mobile OS

Now that most mobile phones use operating systems in a similar way to desktop computers, you are more likely to want to change your OS. Typically you can change your mobile OS to a newer version of that OS, but some phone users have had experience changing the operating system entirely, rather than just the version. Note, however, that changing to an unofficial OS will likely void your warranty.

Instructions

  1. 1
    Upgrade the BB OS if you use a BlackBerry smart phone. BlackBerry's do not accept any other type of operating system, but Research in Motion (RIM) does upgrade the OS quite significantly with each release. OS 6 is the latest version (as of February 2011) and you can download it from the main BlackBerry website.
  2. 2
    Experiment if you have an iPhone. iPhones are typically the most closed-source mobile phones, but if you jailbreak your iPhone then you have many more possibilities. You can hack an iPhone to run Linux or early versions of Windows. This will be a complex process and will not be easy for a beginner.
  3. 3
    Upgrade your other OS using the relevant websites. Android releases new versions of their operating system as does Windows Phone (previously Windows Mobile). Windows Phone completely redesigns the user interface from earlier versions.