June 21, 2024, 02:41:56 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


strange errors...

Started by ExMember001, August 13, 2006, 12:27:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ExMember001

August 13, 2006, 12:27:29 AM Last Edit: August 13, 2006, 12:33:03 AM by krypt
when i was using the sapero's include files this code was working perfect ;)

now i've decide to make it independant from it ...
but now it seems that this is returning me some strange errors and i cannot find the problem.

Errors :
Compiling...
SystemAPI.src
File: C:\...\Custom subs\SystemAPI.src (153) Warning: local data size 63756 bytes in subroutine 'GetSysUsername'
File: C:\...\Custom subs\SystemAPI.src (228) Warning: local data size 65596 bytes in subroutine 'GetWinOSName'
File: C:\...\Custom subs\SystemAPI.src (314) Warning: local data size 32936 bytes in subroutine 'GetWinOSProductTypeNT'

No Errors

Linking...
Aurora Linker v1.0 Copyright ÂÃ,©2005,2006 Ionic Wind Software
Unresolved external main
Error: Unresolved extern main
Error: Unresolved extern __imp_GetUserName
Error(s) in linking C:\Documents and Settings\Martin\Mes documents\Aurora source\Custom subs\SystemAPI.exe

code:

////////////////////////////////////////////////////////////////////////////////
// System API Subroutines
////////////////////////////////////////////////////////////////////////////////
/*
extern void   GetSysFonts(int hdc);
extern int    GetSysFontsCallback(LOGFONT lpNLF,NEWTEXTMETRIC lpNTM, int FontType, int LParam);
extern string GetSysUsername();
extern string GetWinOSName();
extern string GetWinOSProductTypeNT();
extern string GetWinOSServicePack();
*/

struct OSVERSIONINFO
{
int dwOSVersionInfoSize;
int dwMajorVersion;
int dwMinorVersion;
int dwBuildNumber;
int dwPlatformId;
string szCSDVersion[128];
}

struct OSVERSIONINFOEX
{
int dwOSVersionInfoSize;
int dwMajorVersion;
int dwMinorVersion;
int dwBuildNumber;
int dwPlatformId;
string szCSDVersion[128];
int wServicePackMajor;
int wServicePackMinor;
int wSuiteMask;
int wProductType;
int wReserved;
}

struct LOGFONT
{
  int lfHeight;
  int lfWidth;
  int lfEscapement;
  int lfOrientation;
  int lfWeight;
  int lfItalic;
  int lfUnderline;
  int lfStrikeOut;
  int lfCharSet;
  int lfOutPrecision;
  int lfClipPrecision;
  int lfQuality;
  int lfPitchAndFamily;
  string lfFaceName[LF_FACESIZE];
}

struct NEWTEXTMETRIC
{
    int        tmHeight;
    int        tmAscent;
    int        tmDescent;
    int        tmInternalLeading;
    int        tmExternalLeading;
    int        tmAveCharWidth;
    int        tmMaxCharWidth;
    int        tmWeight;
    int        tmOverhang;
    int        tmDigitizedAspectX;
    int        tmDigitizedAspectY;
    int        tmFirstChar;
    int        tmLastChar;
    int        tmBreakChar;
    int        tmItalic;
    int        tmUnderlined;
    int        tmStruckOut;
    int        tmPitchAndFamily;
    int        tmCharSet;
    int        ntmFlags;
    unsigned int    ntmSizeEM;
    unsigned int    ntmCellHeight;
    unsigned int    ntmAvgWidth;
}

import int     EnumFontFamilies alias EnumFontFamiliesA(int hdc, int lpLogfont, pointer lpProc, int lParam);
import pointer lstrcpyn alias lstrcpynA(pointer lpString1,pointer lpString2,int iMaxLength);
import int     GetUserName(pointer lpBuffer,pointer lpnSize);
import int     GetVersionExA(OSVERSIONINFO lpVersionInformation);

#define TRUETYPE_FONTTYPE  0x0004

#define VER_PLATFORM_WIN32s          0
#define VER_PLATFORM_WIN32_WINDOWS   1
#define VER_PLATFORM_WIN32_NT        2
#define VER_NT_WORKSTATION         1
#define VER_NT_DOMAIN_CONTROLLER   2
#define VER_NT_SERVER              3
#define VER_SUITE_SMALLBUSINESS  1
#define VER_SUITE_ENTERPRISE     2
#define VER_SUITE_TERMINAL       16
#define VER_SUITE_DATACENTER     128
#define VER_SUITE_SINGLEUSERTS   256
#define VER_SUITE_PERSONAL       512
#define VER_SUITE_BLADE          1024

////////////////////////////////////////////////////////////////////////////////
// Find system fonts then write them to a tmp ascii file..
Global sub GetSysFonts(int hdc)
{
//Call Api, Font is retrieve from the callback
EnumFontFamilies(hdc,null,&GetSysFontsCallback,0);

return true;
}

//everytime a font is found these callback occur.
Global sub GetSysFontsCallback(LOGFONT lpNLF,NEWTEXTMETRIC lpNTM, int FontType, int LParam),int
{

    string fontname;
int TmpFile;

// get fontname into a string
lstrcpyn(fontname,lpNLF.lfFaceName,32);

////////write what you do with the fontname here

//return true type fonts only
If (FontType = TRUETYPE_FONTTYPE)
{
    //Put fontname into a tmp ascii file
    TmpFile = OpenFile(getstartpath() + "tmp.txt" ,MODE_WRITE|MODE_APPEND);
    if(TmpFile)
    {
fontname = rtrim$(ltrim$(fontname));
    fontname += "\n";
    Write(TmpFile,fontname,len(fontname));
    CloseFile(TmpFile);
    }
}

// return true to continue to retrieve fontname
return true;
}

////////////////////////////////////////////////////////////////////////////////
// return the current user name 
Global Sub GetSysUsername(),string
{
    string name[250];
    Int buffer;

    buffer = 251;
    GetUserName(name, buffer);
}

////////////////////////////////////////////////////////////////////////////////
// return current window version name
Global sub GetWinOSName(),string
{
    OSVERSIONINFO OsV;
    OSVERSIONINFOEX OsVnfo;

    String Os_vs;

    OsV.dwOSVersionInfoSize = Len(OsV);
    GetVersionExA(OsV);

    SELECT OsV.dwPlatformId
    {

        CASE VER_PLATFORM_WIN32s:

            Os_vs  = "Win32s";

    CASE VER_PLATFORM_WIN32_WINDOWS:

    if (OsV.dwMajorVersion = 4) & (OsV.dwMinorVersion = 0)
    {
              Os_vs = "Windows 95";
    }

            if (OsV.dwMajorVersion = 4) & (OsV.dwMinorVersion = 10)
        {
                Os_vs = "Windows 98 ";

                if (OSV.szCSDVersion = "A") | (OSV.szCSDVersion = "B")
        {
        Os_vs = "Windows 98 Second Edition";
        }
        }

            if (OsV.dwMajorVersion = 4) & (OsV.dwMinorVersion = 90)
        {
        Os_vs = "Windows Millennium Edition";
            }


        CASE VER_PLATFORM_WIN32_NT:
               
            if OsV.dwMajorVersion = 3
    {
        Os_vs = "Windows NT 3.51";
    }

            if OsV.dwMajorVersion = 4
    {
        Os_vs = "Windows NT 4.0";
    }

            if OsV.dwMajorVersion = 5
    {
    select OsV.dwMinorVersion
    {
        case 0:
    Os_vs = "Windows 2000";
    case 1:
        Os_vs = "Windows XP";
    case 2:
        Os_vs = "Windows 2003 Server";
    }
    }

            if OsV.dwMajorVersion = 6 & OsVnfo.dwMinorVersion = 0
    {
    Os_vs = "Windows Vista";
    }
    }
return Os_vs;
}

////////////////////////////////////////////////////////////////////////////////
// return current windows version type
Global sub GetWinOSProductTypeNT(),string
{
    OSVERSIONINFOEX OsVnfo;

    String Os_Type;

    OsVnfo.dwOSVersionInfoSize = Len(OsVnfo);
    GetVersionExA(OsVnfo);

select OsVnfo.dwMajorVersion
{
case 4:
    select OsVnfo.wProductType
{
// Windows NT 4.0 Workstation
case VER_NT_WORKSTATION:
    Os_Type = "Workstation";
// Windows NT 4.0 Server
case VER_NT_SERVER:
    Os_Type = "Server";
}

case 5:
    select OsVnfo.wProductType
{
case VER_NT_WORKSTATION:
    if OsVnfo.wSuiteMask = VER_SUITE_PERSONAL
{
// Windows XP Home Edition
Os_Type = "Home Edition";
}
else
{
// Windows XP / Windows 2000 Professional
                        Os_Type = "Professional";
}

case VER_NT_SERVER:
    select OsVnfo.dwMinorVersion
        {
            case 0: // Windows 2000
    if OsVnfo.wSuiteMask = VER_SUITE_DATACENTER
        {
        // Windows 2000 Datacenter Server
        Os_Type = "Datacenter Server";
        }
else if OsVnfo.wSuiteMask = VER_SUITE_ENTERPRISE
{
/// Windows 2000 Advanced Server
        Os_Type = "Advanced Server";
}
else
{
/// Windows 2000 Server
        Os_Type = "Server";
}

        case 2: // Windows Server 2003
    if OsVnfo.wSuiteMask = VER_SUITE_DATACENTER
        {
        // Windows Server 2003 Datacenter Edition
        Os_Type = "Datacenter Server";
        }
else if OsVnfo.wSuiteMask = VER_SUITE_ENTERPRISE
{
// Windows Server 2003 Enterprise Edition
        Os_Type = "Enterprise Edition";
}
else if OsVnfo.wSuiteMask = VER_SUITE_BLADE
{
// Windows Server 2003 Web Edition
        Os_Type = "Web Edition";
}
else
{
// Windows Server 2003 Standard Edition
        Os_Type = "Standard Edition";
}
        }
}
}
return Os_Type;
}

////////////////////////////////////////////////////////////////////////////////
// return the current Service Pack into a string
global Sub GetWinOSServicePack(),string
{
OSVERSIONINFOEX OsVnfo;

    OsVnfo.dwOSVersionInfoSize = Len(OsVnfo);
    GetVersionExA(OsVnfo);

if len(OsVnfo.szCSDVersion) <> 0
{
return OsVnfo.szCSDVersion;
}
else
{
return "";
}
}


What's Happen ?


Ionic Wind Support Team

string name[250];

Is 250 * 255 characters  = 63K

I think you meant:

dstring name[250];

Same thing for your two structures,  They are both wrong.  The compiler warns you when it sees a large stack being used as it is unusual.  You can ajust stack size if you really need it.  But the warning is there to catch mistakes like this.

Paul.

Ionic Wind Support Team

Ionic Wind Support Team

Also the name of that import is wrong.  It's GetUserNameA
Ionic Wind Support Team

ExMember001

thx 1 part is resolved :)

for getusernameA its seems the 2 are correct
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getusername.asp

but even if i change it i get the same errors
Error: Unresolved extern __imp_GetUserNameA

Ionic Wind Support Team

#use "advapi32.lib"

The microsoft docs tell you what library the import is located in.
Ionic Wind Support Team

ExMember001

ha! :)  i didnt notice that !
thank you.

Zen

Just out of interest, Which librarys are included by default when we compile through the IDE? I know with Aurora Live i had to create my own list that it would include (depending on the compile type), forgot which ones now, but just incase i have some missing i thought it would be a good idea to check.

Lewis

Ionic Wind Support Team

Most of the ones in the .lib directory if your speaking of import libraries.
Ionic Wind Support Team

Zen

Hmm well i need to boot up the server tomorrow i think and check my list, i know i havnt added the ones required for the database, 2D and 3D libraries yet. Hmm shows how long its been since i have worked on it.

Lewis