Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Hiding and Storing/caching of Application Specific data in MS Word 2003 documents

, 9 Oct 2008
Proof of concept on how the application specific (small/large amount of) data can be stored in ms word document as well as how it can be made hidden from end user’s eye.
Proof_Of_Concept.zip
Common
Common
bin
Debug
Release
Common.dll
Common.pdb
obj
Debug
TempPE
Release
Common.dll
Common.pdb
TempPE
Properties
Common.suo
DocumentIDReader
DocumentIDReader
bin
Debug
Release
DocumentIDReader.exe
DocumentIDReader.pdb
DocumentIDReader.vshost.exe
DocumentIDReader.csproj.user
obj
Debug
TempPE
Release
DocumentIDReader.csproj.GenerateResource.Cache
DocumentIDReader.exe
DocumentIDReader.Form1.resources
DocumentIDReader.pdb
DocumentIDReader.Properties.Resources.resources
TempPE
Properties
Settings.settings
DocumentIDReader.suo
FileStorage
FileStorage
FileStorage.def
FileStorage.vcproj.NECHCLDC01.atul.suyal.user
FileStorage.vcproj.NECHCLDC01.vinita.batra.user
FileStorage.vcproj.RAIREKI.mahendra.gupta.user
res
vssver2.scc
vssver2.scc
FileStorage.suo
SocketServer
SocketServer
bin
Release
Common.dll
Common.pdb
SocketServer.exe
SocketServer.pdb
SocketServer.vshost.exe
obj
Debug
SocketServer.exe
SocketServer.pdb
TempPE
Release
SocketServer.exe
SocketServer.pdb
TempPE
Properties
SocketServer.csproj.user
SocketServer.suo
WordAddIn1
WordAddIn1
bin
Debug
Common.dll
Common.pdb
WordAddIn1.dll
WordAddIn1.dll.manifest
WordAddIn1.pdb
obj
Debug
TempPE
WordAddIn1.csproj.GenerateResource.Cache
WordAddIn1.csproj.ResolveComReference.cache
WordAddIn1.dll
WordAddIn1.pdb
WordAddIn1.Properties.Resources.resources
Properties
Settings.settings
WordAddIn1.csproj.user
WordAddIn1.suo
WordAddIn1Setup
Debug
Release
WordAddIn1Setup
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;


namespace Common
{
    public class FileOperation
    {
        [DllImport("FileStorage.dll", CharSet = CharSet.Unicode)]
        public static extern Boolean AddDataToFile(string fileName, int typeOfData, string data, Int32 officeFile);
        [DllImport("FileStorage.dll", CharSet = CharSet.Unicode)]
        public static extern Boolean ReadDataFromFile(string fileName, int typeOfData, string data, UInt32 datasize, Int32 officeFile);

        public Boolean AddData(string fileName, int typeOfData, string data)
        {
            //Adds the DocumentID in the file specified by fileName by calling 
            //AddDataToFile() which is exported by FileStorage.dll
            
            Boolean retVal = false;
            try
            {
                retVal = AddDataToFile(fileName, typeOfData, data, 1);
            }
            catch (Exception e)
            {
            }
            finally
            {
            }
            return retVal;
        }

        public Boolean ReadData(string fileName, int typeOfData, ref string data, UInt32 datasize)
        {
            //Reads the DocumentID in the file specified by fileName by calling 
            //ReadDataFromFile() which is exported by FileStorage.dll
            Boolean retVal = false;
            char[] temp = new char[260];
            data = new string(temp);
            try
            {
                retVal = ReadDataFromFile(fileName, typeOfData, data, 260, 1);
                data = data.Replace('\0', ' ');
                data = data.Trim();
            }
            catch (Exception e)
            {
            }
            finally
            {
            }
            return retVal;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 10 Oct 2008
Article Copyright 2008 by batra.vinita@gmail.com
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid