?
Solved

Putting my chapters into a text file and opening it from a rich textbox

Posted on 2007-07-30
9
Medium Priority
?
201 Views
Last Modified: 2010-04-30
I have 114 Chapters of text. My problem is, I want to put all those chapters into a single file, encrypt the file so no one knows about it, and get my application to open chapters from that file and display them in my rich text box.

How do I go along about doing this?

It is confusing when I download other software, they hide their information I don't know where. For example, I remember opening a software and I clicked a button and  it displayed a huge amount of information in its text box. Now, when I search that softwares folder, I seem to not find where the information I saw in the text box cam from. So I look at their files, it seems like they use .dll or they created their own file extension and encrypted their information so nobody knows where their information comes from. How can I do the same as ANY other programmer?

I hope this is clear. Thanks.
0
Comment
Question by:Zeyadss
  • 5
  • 4
9 Comments
 
LVL 13

Accepted Solution

by:
Mark_FreeSoftware earned 400 total points
ID: 19596805

there are a few ways to go, this is a thing i did:

add all text files as resource in your program, or a separate dll.
(eventually compress/encrypt it yourself also)
now create a new file, and use this as an index.
0
 
LVL 2

Author Comment

by:Zeyadss
ID: 19597037
I have tried using .res file. I added a few files, but when I open the .res file in notepad it showed most of the files information. It is not hidden or encrypted.
Is this how a .res file is suppose to be?
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 19597088

i thought res files were compressed, but they appear not to be.
this should work, although it may be a little overhead:

grab yourself a copy of the zlib library, and compress each file before adding it to a resource

optionally, add all (compressed) files in one file, and seperate them with a delimiter, or save the offsets where each new file start


for example, code to compress/decompress a byte array (i cant claim its my code, found it somewhere on the internet, and modified it)



Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)

Private Declare Function compress2 Lib "p_zlib.dll" (dest As Any, destLen As Any, src As Any, ByVal srcLen As Long, ByVal level As Long) As Long
Private Declare Function uncompress Lib "p_zlib.dll" (dest As Any, destLen As Any, src As Any, ByVal srcLen As Long) As Long


Private Function CompressByteArray(TheData() As Byte, CompressionLevel As Integer) As Long
Dim result As Long
Dim BufferSize As Long
Dim TempBuffer() As Byte


    'Allocate memory for byte array
    BufferSize = UBound(TheData) + 1
    BufferSize = BufferSize + (BufferSize * 0.01) + 15
    ReDim TempBuffer(BufferSize)
   
    'Compress byte array (data)
    result = compress2(TempBuffer(0), BufferSize, TheData(0), UBound(TheData) + 1, CompressionLevel)
   
    'Truncate to compressed size
    ReDim Preserve TheData(BufferSize - 1)
    CopyMemory TheData(0), TempBuffer(0), BufferSize
   
    'Cleanup
    Erase TempBuffer
   
    CompressByteArray = result
End Function


Private Function DecompressByteArray(TheData() As Byte, OrigSize As Long) As Long
Dim result As Long
'Allocate memory for buffers
Dim BufferSize As Long
Dim TempBuffer() As Byte

    BufferSize = OrigSize
    BufferSize = BufferSize + (BufferSize * 0.01) + 12
    ReDim TempBuffer(BufferSize)
   
    'Decompress data
    result = uncompress(TempBuffer(0), BufferSize, TheData(0), UBound(TheData) + 1)
   
    'Truncate buffer to compressed size
    ReDim Preserve TheData(BufferSize - 1)
    CopyMemory TheData(0), TempBuffer(0), BufferSize
   
    'Return error code (if any)
    DecompressByteArray = result
End Function
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Author Comment

by:Zeyadss
ID: 19597109
Ok I understand. Lastly, can .rtf files also be put into .res files? especially sound files?
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 19597142

all files can be put in a resource file, you just have to know how to extract it

0
 
LVL 2

Author Comment

by:Zeyadss
ID: 19597144
I have raised points to 100 for the extra question I asked. Thanks a lot. It has actually been years since I tred finding a way to hide files. .res sounds much more easier.
0
 
LVL 2

Author Comment

by:Zeyadss
ID: 19597154
Is it possible I ask you another question? How do I do this?
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 19597158
just ask another question, and if you really want me to look at it, post a link here



thanks for the points, and the grade!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question