tewehuang
asked on
i just want to read info. *.ini file.
if i have a code
wsprintf(szName,"f:\\amgin l\\amginl% s.bmp",csc );
DBChart1->SaveToBitmapFile (szName);
.
but now i want to write the path "f:\\amginl\\"in test.ini file.
and auto load the test.ini file to do
like a first code.how will i do ?
i think the code mabe is:
fopen("test.ini:);
...........
.........
wsprintf(szName,"%samginl% s.bmp",aaa ,csc);
DBChart1->SaveToBitmapFile (szName);
please tell me how will i do?
thanks.
wsprintf(szName,"f:\\amgin
DBChart1->SaveToBitmapFile
.
but now i want to write the path "f:\\amginl\\"in test.ini file.
and auto load the test.ini file to do
like a first code.how will i do ?
i think the code mabe is:
fopen("test.ini:);
...........
.........
wsprintf(szName,"%samginl%
DBChart1->SaveToBitmapFile
please tell me how will i do?
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Really proskig is right... That's the easier way to read an INI file...
100 pts. to proskig :-)
But you ask for fopen, isn't it?
;-)
100 pts. to proskig :-)
But you ask for fopen, isn't it?
;-)
ASKER
i just try to writed som code to go.
my source code is:
//------------------------ ---------- ---------- ---------- ---------- ---------- -
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include "Unit1.h"
FILE *file1;
FILE *file2;
//------------------------ ---------- ---------- ---------- ---------- ---------- -
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//------------------------ ---------- ---------- ---------- ---------- ---------- -
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//------------------------ ---------- ---------- ---------- ---------- ---------- -
void __fastcall TForm1::FormCreate(TObject *Sender)
{
while(!Query1->Eof)
{
file1 = fopen("c:\\amginl.ini","r" );
file2 = fopen("c:\\amgins.ini","r" );
String aaa,bbb ;
fscanf(file1,"%s",aaa);
fscanf(file2,"%s",bbb);
char szName[255];
// get data from first table
// and save data into csc
String csc = Query1->FindField("STKCODE ")->AsStri ng;
String mkt = Query1->FindField("MKT")-> AsString;
// into csc to second table and get data
if(mkt == "TSE"){
Query2->Close();
Query2->SQL->Clear();
Query2->SQL->Add("select stkcode,syear*100+smon,sb_ vol,lb_vol ,cp");
Query2->SQL->Add("from ap.amgin");
Query2->SQL->Add("where STKCODE =:sss");
Query2->ParamByName("sss") ->AsString = csc;
Query2->Active=TRUE;
// use the data of second table to draw the line chart
Series1->DataSource=Query2 ;
Series1->ParentChart=DBCha rt1;
Series1->XLabelsSource="sy ear*100+sm on";
Series1->YValues->ValueSou rce= "lb_vol";
Series2->DataSource=Query2 ;
Series2->ParentChart=DBCha rt2;
Series2->XLabelsSource="sy ear*100+sm on";
Series2->YValues->ValueSou rce= "cp";
wsprintf(szName,"%s\\amgin l%s.bmp",a aa,csc);
DBChart1->SaveToBitmapFile (szName);
Series3->DataSource=Query2 ;
Series3->ParentChart=DBCha rt2;
Series3->XLabelsSource="sy ear*100+sm on";
Series3->YValues->ValueSou rce= "sb_vol";
Series4->DataSource=Query2 ;
Series4->ParentChart=DBCha rt1;
Series4->XLabelsSource="sy ear*100+sm on";
Series4->YValues->ValueSou rce= "cp";
wsprintf(szName,"%s\\agmgi ns%s.bmp", bbb,csc);
DBChart2->SaveToBitmapFile (szName);
Query1->Next();
}
but i get some error message.
the message is:
access violation at address 3245c386 in module 'cp3245mt.dll".write of address 00000000
my source code is:
//------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include "Unit1.h"
FILE *file1;
FILE *file2;
//------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//------------------------
__fastcall TForm1::TForm1(TComponent*
: TForm(Owner)
{
}
//------------------------
void __fastcall TForm1::FormCreate(TObject
{
while(!Query1->Eof)
{
file1 = fopen("c:\\amginl.ini","r"
file2 = fopen("c:\\amgins.ini","r"
String aaa,bbb ;
fscanf(file1,"%s",aaa);
fscanf(file2,"%s",bbb);
char szName[255];
// get data from first table
// and save data into csc
String csc = Query1->FindField("STKCODE
String mkt = Query1->FindField("MKT")->
// into csc to second table and get data
if(mkt == "TSE"){
Query2->Close();
Query2->SQL->Clear();
Query2->SQL->Add("select stkcode,syear*100+smon,sb_
Query2->SQL->Add("from ap.amgin");
Query2->SQL->Add("where STKCODE =:sss");
Query2->ParamByName("sss")
Query2->Active=TRUE;
// use the data of second table to draw the line chart
Series1->DataSource=Query2
Series1->ParentChart=DBCha
Series1->XLabelsSource="sy
Series1->YValues->ValueSou
Series2->DataSource=Query2
Series2->ParentChart=DBCha
Series2->XLabelsSource="sy
Series2->YValues->ValueSou
wsprintf(szName,"%s\\amgin
DBChart1->SaveToBitmapFile
Series3->DataSource=Query2
Series3->ParentChart=DBCha
Series3->XLabelsSource="sy
Series3->YValues->ValueSou
Series4->DataSource=Query2
Series4->ParentChart=DBCha
Series4->XLabelsSource="sy
Series4->YValues->ValueSou
wsprintf(szName,"%s\\agmgi
DBChart2->SaveToBitmapFile
Query1->Next();
}
but i get some error message.
the message is:
access violation at address 3245c386 in module 'cp3245mt.dll".write of address 00000000
ASKER
Adjusted points from 80 to 110
ASKER
ok...sorry.i don't know the "ini" value.
so.i update the points.
but i just try the solution.
but get some trouble.
do you know what's happen?
so.i update the points.
but i just try the solution.
but get some trouble.
do you know what's happen?
ASKER
ok...sorry.i don't know the "ini" value.
so.i update the points.
but i just try the solution.
but get some trouble.
do you know what's happen?
so.i update the points.
but i just try the solution.
but get some trouble.
do you know what's happen?
GetPrivateProfileString("Y
After it szBuffer contains value for a key "Bitmap file" under section "Your section in INI file". You might want to check registry functions documentation (e.g. in MSDN)